Skip to content

Predict

2 messages · Smit, M.J., Roger Bivand

#
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
#
On Fri, 30 Mar 2012, Smit, M.J. wrote:

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