Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In R plot arima fitted model with the original series

Tags:

I was using GRETL. There, when I do the forecasting for the validation of the arima model, I will get the fitted series in blue line and the original series in red line. Later, I switched to R and here I could not find any command to do the same. I am using Arima model from forecast package.

details,

In GRETL I use to do model->time series -> arima -> forecast. It will automatically print the fitted and the original series. Any idea to do the same on R?

like image 810
Pankaj Parag Avatar asked Jul 21 '11 21:07

Pankaj Parag


2 Answers

This question is fairly open ended, but here is a very, very basic answer. Starting directly from one of the examples provided in the help files for Arima in the forecast package:

fit <- Arima(WWWusage,order=c(3,1,0))

You say you want the original series in red and the fitted series in blue:

plot(fit$x,col="red")
lines(fitted(fit),col="blue")

which produces a plot that looks something like this:

arima

like image 117
joran Avatar answered Sep 17 '22 17:09

joran


The differences you are finding are because the arima() function is different from the Arima() function. The former is contained in the basis stats package, the lattercomes from the package forecast and includes the fitted() function to predict over the observed values.

like image 29
paul Avatar answered Sep 20 '22 17:09

paul