[R] Out of sample forecast

David Winsemius dwinsemius at comcast.net
Tue Apr 6 18:35:35 CEST 2010


On Apr 6, 2010, at 12:25 PM, Luis Felipe Parra wrote:

> Hello I am trying to use predict, but I am having trouble getting  
> out of
> sample predictions. I am getting the same output if I use the  
> following
> three commands:
>
> predict(ModeloLineal,predictors[721:768,])
> predict(ModeloLineal,predictors[1:768,])
> predict(ModeloLineal)

I think you need to look at:

?predict

... with particular effort toward closely reading about the newdata  
argument.

>
> where ModeloLineal is the output from ModeloLineal<-lm(dataTS[,6] ~
> predictors[1:720,]), so the first 720 observations of predictors i  
> would
> like to use them to build my model and the other 48 I would like to  
> use them
> to have an out of sample forecast. When I give the three commands I am
> always getting 161 predictions backwards, not forward as I expect.  
> Do you
> know how can I do this?
>
> Thank you
>
> Felipe Parra
>

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list