On Fri, 24 Apr 2009, evans...@umn.edu wrote:

Hi Roger,

Then the dak_test_data is a SpatialPolygonsDataFrame, for which there is no nrow() method, leading to problems. Please get around this by saying newdata=as(dak_test_data, "data.frame") to coerce it to data frame. I'll look at providing dim methods for Spatial*DataFrame objects other than SpatialPointsDataFrame, which are in sp already; nrow() just returns dim()[1] of the object.

Thanks for your help so far. I tried your suggestion using the following code:

dak_test_vars.10nn.predict <- predict.sarlm(reg_vars_formula.lag, newdata=as(dak_test_vars, "data.frame"), listw = dak_test.10nn.listw,zero.policy=TRUE)

Now I get a new error message: "Error in invIrW(listw, object$rho) %*% trend : non-conformable arguments". I double checked the listw object and data frame properties. They are as follows:

nrow(as(dak_test_vars, "data.frame") = 2255
length(dak_test.10nn.listw)
[1] 3
names(dak_test.10nn.listw)
[1] "style"      "neighbours" "weights"   length(dak_test.10nn.listw[[2]])
[1] 2255
length(coords_test)
[1] 4510

The lengths are OK now - the final one is just 2*2255, so the length of all the elements in a two-column matrix.

The problem is occurring in multiplying (I - rho W)^{-1} by the product of the newdata X values and the fitted regression coefficients - and suggests that something else is going wrong earlier. If you know how to run debug(), then do debug(predict.sarlm) and step through, checking the dimensions and values of B and X used to create trend. If this sounds scary, do:

save(reg_vars_formula.lag, dak_test_vars, dak_test.10nn.listw, file="predict_problem.RData")

and attach the saved file to me offlist, and I'll try to see what is going on.

Roger


I am unsure of how to interpret this error. Do you have any advice? Thanks for your help.

Heather






--
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

Reply via email to