On Wed, 22 Apr 2009, evans...@umn.edu wrote:
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)
Thanks for providing the verbatim code. If this is the verbatim code, then
newdata = "dak_test_data" is saying that newdata is not the data.frame
object called dak_test_data, but a single element character vector - that
is, nrow("dak_test_data") is NULL. However, this does not trigger the
error message as such, so it could also be that you wrote newdata =
dak_test_data, and nrow(dak_test_data) is not equal to
length(dak_test.10nn.listw) - or here nrow(coords), which is the test.
Hope this helps,
Roger
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
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo