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