Hello,

   I intend to perform FORECASTING with the  "dynlm" package since I have a
bunch of time series data, and my model is a little deviating from the
standard AR. Therefore my first attempt is to perform AR forecasting based
on dynlm package.
   First of all, I generate an ARIMA model and then fit it to an AR(4)
process. I also plot the confidence interval.

x = arima.sim(list(order=c(1,0,1), ar=.9, ma=-.5), n=100)
x.fit<-ar(x,aic=FALSE, order.max=4)
x.fore<-predict(x.fit, n.ahead=10)
# plot the forecasts
U = x.fore$pred + 2*x.fore$se
L = x.fore$pred - 2*x.fore$se
minx=min(x,L)
maxx=max(x,U)
ts.plot(x,x.fore$pred,col=1:2, ylim=c(minx,maxx))
lines(U, col="blue", lty="dashed")
lines(L, col="blue", lty="dashed")

    Attempting to do the same thing via dynlm function, I added the codes

x1.fit<-dynlm(x~L(x,1:4))
x1.fore<-predict(x1.fit,n.ahead=10,se.fit=TRUE)

    Nevertheless, I do not get the forecasts.
    1. How can I fix the code to get the same results?  Do I need to
specify "newdata"? How?
    2. The AR4 coefficients and the dynlm coefficients are not exactly the
same. Why?

    Thanks,

miao

	[[alternative HTML version deleted]]

