R - 局部 Moran’s I Bonferroni 调整失败
我正在尝试从 R 中的 sp 包运行本地 Moran's I,但无法在代码中包含 bonferroni 调整。我可以在没有 p.adjust 代码的情况下运行 localmoran 函数,没有问题,但调整代码的所有变体都没有成功运行。我在下面添加了代码的两个变体以及返回的错误。
library(spdep)
library(rgdal)
gb<-readOGR("gb_corrected.shp")
attach(gb@data)
gb.adj.listw<-nb2listw(poly2nb(gb), style = "W")
lmi78 <- localmoran(GDPPC78, gb.adj.listw, p.adjust.method ="bonferroni", alternative = "two.sided")
错误:
“localmoran 中的错误(GDPPC78,gb.adj.listw,p.adjust.method = "bonferroni", : 未使用的参数 (p.adjust.method = "bonferroni")"
lmi78<-localmoran(GDPPC78, gb.adj.listw, p.adjust(method ="bonferroni"), alternative = "two.sided")
错误:
“p.adjust(method = "bonferroni") 中的错误:参数“p”是 缺失,无默认值”
我的 R 版本如下,这里的所有软件包都是最新的。我在 R 和 R Studio 中都尝试过。对于任何丢失的信息,我深表歉意,这是我第一次在这里发帖。
RStudio 2022.02.0+443“草原延龄草”版本(9f7969398b90468440a501cf065295d9050bb776, 2022-02-16) 适用于 Windows Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,如 Gecko)QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36
I'm trying to run a local Moran's I from the sp package in R and am unable to include a bonferroni adjustment in the code. I can run the localmoran function without the p.adjust code no problem, but none of the variations of the adjustment code run successfully. I've added two variations of my code below along with the errors that are returned.
library(spdep)
library(rgdal)
gb<-readOGR("gb_corrected.shp")
attach(gb@data)
gb.adj.listw<-nb2listw(poly2nb(gb), style = "W")
lmi78 <- localmoran(GDPPC78, gb.adj.listw, p.adjust.method ="bonferroni", alternative = "two.sided")
Error:
"Error in localmoran(GDPPC78, gb.adj.listw, p.adjust.method =
"bonferroni", : unused argument (p.adjust.method = "bonferroni")"
lmi78<-localmoran(GDPPC78, gb.adj.listw, p.adjust(method ="bonferroni"), alternative = "two.sided")
Error:
"Error in p.adjust(method = "bonferroni") : argument "p" is
missing, with no default"
My version of R is below and all packages here are up-to-date. I have tried in both R and R Studio. I apologize for any missing information, this is my first time posting here.
RStudio 2022.02.0+443 "Prairie Trillium" Release (9f7969398b90468440a501cf065295d9050bb776, 2022-02-16) for Windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论