[R] using predict.lm function
David Winsemius
dwinsemius at comcast.net
Sun May 22 21:21:14 CEST 2011
On May 22, 2011, at 12:35 PM, Dave Evens wrote:
>
> 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.
There is a 'forecast' package.
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list