[R] using the predict function

From: Dave Evens <daveevens1_at_yahoo.co.uk>
Date: Mon, 16 May 2011 19:34:46 +0100 (BST)

Dear all,

I'm fitting a linear model with numerous lag terms of the response variable [i.e. y(t-1), y(t-2),y(t-3)...,] and other explanatory variables [x(1), x(2), x(3),....]- which go into my design matrix X.

I'm fitting the linear model: lm(Y ~ X, ...).

I would like to use the predict.lm function however the future predictions of Y are dependent upon previous predictions of Y [i.e. the response lag terms]. Does anyone know how I would go about using predict.lm to make future forecasts of Y? Or, does this have to be writting as a for loop that recursively updates the lag terms for each future prediction of y(i)? The data is a time series and the model is only calculated once in order to make the future predictions.

Thanks,

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 16 May 2011 - 22:15:32 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 16 May 2011 - 22:20:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive