Skip to content
Prev 5567 / 29559 Next

error using predict.sarlm

I am encountering difficulties using predict.sarlm to make predictions for 
a SAR lag model generated using lagsarlm and a new dataset. I used the 
following code to do so:

dak_test.10nn.predict <- predict.sarlm(reg_vars_reduced2.10nn.lag, newdata 
= "dak_test_data", listw = dak_test.10nn.listw, zero.policy = TRUE)

When I run this, I get the following error message: "Error in if 
(nrow(newdata) != length(listw$neighbours)) stop("mismatch between newdata 
and spatial weights") : argument is of length zero"

I recognize that there is a problem with my listw object, but am not sure 
how to handle it. I produced the listw using the following code sequence:

dak_test.10nn <- knearneigh(coords, k=10)
dak_test.10nn.nb <- knn2nb(dak_test.10nn, row.names=rn, sym=TRUE)
dak_test.10nn.listw <- nb2listw(dak_test.10nn.nb, zero.policy=TRUE)

Can anyone offer me some guidance in solving this problem? Thanks for your 
help.

Heather Sander