Hi:


On Sat, Aug 21, 2010 at 9:29 AM, Xiyan Lon <xiyanlon@gmail.com> wrote:

> Dear All,
>
> I have a model to predict time series data for example:
>
> data(LakeHuron)
> Lake.fit <- arima(LakeHuron,order=c(1,0,1))
>

This is what Lake.fit contains (an object of class Arima):

> names(Lake.fit)
 [1] "coef"      "sigma2"    "var.coef"  "mask"      "loglik"    "aic"
 [7] "arma"      "residuals" "call"      "series"    "code"      "n.cond"
[13] "model"

This provides (gory but necessary) details about the structure of Lake.fit:

> str(Lake.fit)
List of 13
 $ coef     : Named num [1:3] 0.745 0.321 579.055
  ..- attr(*, "names")= chr [1:3] "ar1" "ma1" "intercept"
 $ sigma2   : num 0.475
 $ var.coef : num [1:3, 1:3] 0.00603 -0.00468 0.00177 -0.00468 0.01289 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:3] "ar1" "ma1" "intercept"
  .. ..$ : chr [1:3] "ar1" "ma1" "intercept"
 $ mask     : logi [1:3] TRUE TRUE TRUE
 $ loglik   : num -103
 $ aic      : num 214
 $ arma     : int [1:7] 1 1 0 0 1 0 0
 $ residuals: Time-Series [1:98] from 1875 to 1972: 0.703 1.639 -0.679 0.535
-0.736 ...
 $ call     : language arima(x = LakeHuron, order = c(1, 0, 1))
 $ series   : chr "LakeHuron"
 $ code     : int 0
 $ n.cond   : int 0
 $ model    :List of 10
  ..$ phi  : num 0.745
  ..$ theta: num 0.321
  ..$ Delta: num(0)
  ..$ Z    : num [1:2] 1 0
  ..$ a    : num [1:2] 0.90454 0.00412
  ..$ P    : num [1:2, 1:2] 0 0 0 0
  ..$ T    : num [1:2, 1:2] 0.745 0 1 0
  ..$ V    : num [1:2, 1:2] 1 0.321 0.321 0.103
  ..$ h    : num 0
  ..$ Pn   : num [1:2, 1:2] 1 0.321 0.321 0.103
 - attr(*, "class")= chr "Arima"

To access the residuals of the model, try

Lake.fit$residuals                  # or
resid(Lake.fit)

Some useful plots, perhaps:

plot(resid(Lake.fit))
acf(resid(Lake.fit))
pacf(resid(Lake.fit))

To plot the residuals one lag apart, try this:
res <- resid(Lake.fit)
plot(res[-length(res)], res[-1], xlab = expression(e[t - 1]),
       ylab = expression(e[t]))

HTH,
Dennis

then the function predict() can be used for predicting future data
> with the model:
>
> LakeH.pred <- predict(Lake.fit,n.ahead=5)
>
> I can see the result LakeH.pred$pred and LakeH.pred$se but I did not
> see residual in predict function.
> If I have a model:
>
> [\
> Z_t = Z_{t-1} + A + e_t + B*e_{t-1}
> \]
>
> How could I find $e_t$ dan $e_{t-1}$ ?
>
> Best, XY
>
> ______________________________________________
> R-help@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.
>

	[[alternative HTML version deleted]]

