Dear list members, I want to do a scenario analysis: run a regression on the real data, then make some changes to that, and do a prediction based on the changed data. There is a predict command under sarlm for this, and it works. However, I have two questions. - predict(model,newdata=NULL,weights) uses not only trend (the non-spatial terms) and signal (the spatial "smooth") but also noise (the residuals from the original regression). Is it true I can avoid this by explicitly inserting my old dataset into newdata=? The predictions differ, so something has happened. - predict then gives me a list object, and I'm at a loss how to get the results from this. I've named the objects pred1 and pred2, and vainly tried pred1$trend and pred1[[1]], which gives the first observation from the $trend subvariable, but doesn't allow access to the other subvariables. Is there a way to get this into as.data.frame? Best regards, Martijn
Predict
2 messages · Smit, M.J., Roger Bivand
On Fri, 30 Mar 2012, Smit, M.J. wrote:
Dear list members, I want to do a scenario analysis: run a regression on the real data, then make some changes to that, and do a prediction based on the changed data. There is a predict command under sarlm for this, and it works. However, I have two questions. - predict(model,newdata=NULL,weights) uses not only trend (the non-spatial terms) and signal (the spatial "smooth") but also noise (the residuals from the original regression). Is it true I can avoid this by explicitly inserting my old dataset into newdata=? The predictions differ, so something has happened.
Yes, this is what is happening. In the newdata=NULL case, the response is known, so the signal is defined in terms of the response. If newdata is given, it is defined in terms of the data generation process.
- predict then gives me a list object, and I'm at a loss how to get the results from this. I've named the objects pred1 and pred2, and vainly tried pred1$trend and pred1[[1]], which gives the first observation from the $trend subvariable, but doesn't allow access to the other subvariables. Is there a way to get this into as.data.frame?
I'll add an S3 method to do this. For now, assign the result of the print method to an object: goAway <- capture.output(predsDataFrame <- print(<sarlm.predObject>)) with capture.output() to prevent it printing to screen. The as.data.frame() method is in revision 430 on R-forge. Roger
Best regards, Martijn
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Department of Economics, NHH Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no