no 'nobs' method available: Using the MuMIn package with simultaneous autoregression models

214 views Asked by At

I'm hoping someone can help me figure out why the MuMIn package is not working with my simultaneous autoregression models. I have double checked the documentation for the package and it lists sarlm as one of the supported model types. However, when I try to dredge and average my global SAR models, I get the following error: no 'nobs' method is available. I have tried every workaround that I can think of and still can't figure out where the error is coming from. Any ideas?

Edit: The data frame that I am using contains data for multiple environmental and spatial variables for sites across the continent of Africa. Moran's I indicates that my sites are autocorrelated, hence the use of SAR models instead of traditional OLS. Before creating the model, my data were centered and standardized using the scale() function in spdep. I also created a spatial points data frame and assigned weights based on the nearest neighbor (k=1). I then developed my global model using either errorsarlm. This model had nine predictor variables and four interactions (13 terms total). The error arises when I try to dredge() this model in preparation for averaging it.

Here is my best attempt to recreate the error using the quakes dataset.

quakes <- as.data.frame(quakes)
quakes

#a. Create model
quakes.mod <- glm(quakes$mag ~ quakes$depth + quakes$lat + quakes$long)
summary(quakes.mod)

#b. Convert data frame into spatial point data frame with coordinates 
quakes.df.pt <- SpatialPointsDataFrame(coords=cbind(x = quakes$long, y = quakes$lat), 
                                       data = quakes, 
                                       proj4string= CRS("+init=epsg:4326")) 

#c. Create neighbor matrix. When k = 1, only the closest site will be considered as neighbor
quakes.nb <- knn2nb(knearneigh(quakes.df.pt@coords, k=1, longlat = TRUE))

#d. Check spatial weight by converting to matrix 
quakes.nb.mat <- nb2mat(quakes.nb, style = "W") 
quakes.nb.mat

#e. Generate spatial weight based on neighbor relationship 
quakes.nb.w <- nb2listw(quakes.nb, style="W", zero.policy=T)
quakes.nb.w

#f. Moran's I
lm.morantest(quakes.mod, quakes.nb.w, alternative="two.sided")
      #data are autocorrelated (p = 0.048)

#g. Create global spatial regression model
quakes.reg <- errorsarlm(quakes$mag ~ quakes$depth + quakes$lat + quakes$long,
                         data = quakes, quakes.nb.w,
                         na.action="na.fail")
summary(quakes.reg)

#h. Dredge global model
quakes.dredge <- dredge(quakes.reg, beta = "sd", evaluate = TRUE, rank="AIC")

0

There are 0 answers