[R] question on adding confidence intervals
Spencer Graves
spencer.graves at pdf.com
Sun Nov 6 19:46:43 CET 2005
Have you considered "arima" and "predict.Arima"?
spencer graves
Renuka Sane wrote:
> I am trying to do a forecasting exercise for a series, x. My forecast
> model consists of the following
>
> I first regress log(x) on time and dummy variables for each month.
> lm(log(x) ~ time + monthly dummies)
> I then use predict() to obtain a prediction for the next year.
>
> I then fit an AR(6)/AR(12) model on the residuals of the regression.
> I use predict() here also to obtain the prediction for the next year
>
> My final forecast is the sum of the two predictions i.e. predict.lm
> (from the regression, interval="prediction") and p$pred (from the AR
> model). I then take the exp(of the sum) to plot it against my orginal
> time series. (I assume that the Cov(x,y)=0 and therefore take the exp(sum)).
>
> I now want to draw a confidence interval for my forecast. I realise that
> I will have to add the standard errors from both the regression and the
> AR() model to obtain the final standard error after which I will
> calculate the confidence interval. I realise that I cannot just add the
> two standard errors and take the exp() as in the case of the forecast.
> My question is the following
>
> Can someone help me to obtain the standard error for the final series?
> How do I incorporate the SEs from the AR model? Or is there some other way I
> can
> calculate the confidence interval?
>
> I know that if in predict.lm() I use interval="prediction", I get the
> prediction interval for the yhat. However this is for the regression of
> log(x) on time and monthly dummies. I can make an interval using p$pred
> +-1.96*p$se from the AR model. Again this is for log(x). How can I use these
> two to obtain the final interval for x as opposed to log(x)?
>
> Thanks,
>
> --
> Renuka Sane
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
--
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA
spencer.graves at pdf.com
www.pdf.com <http://www.pdf.com>
Tel: 408-938-4420
Fax: 408-280-7915
More information about the R-help
mailing list