Hello, I am very new to R and Time Series. I need some help including R codes about the following issues. I' ll really appreciate any number of answers... # I have a time series data composed of 24 values: myinput = c(n1,n2...,n24); # In order to make a forecasting a, I use the following codes result1 = arima(ts(myinput),order = c(p,d,q),seasonal = list(order=c(P,D,Q))) result2 = forecast(result1,12) plot(result2) Now, by using R code... 1) How can I determine if my data is statitonary or not ? (trend & seasonal effects) 2) If not, how can I make it stationary ? 3) Is arima() function used only on STATIONARY data ? Or does it first determine if the data is stationary or not and makes it stationary ? (if it is non-stationary) 4) I tried different parameter values in arima() function, but every parameter gave very different results :(( . I even found & tried best.arima() function but it also gave unsatisfactory result. So, how can I calculate the optimum arima() parameters (p,d,q,P,D,Q) that fit my data best ? Thanks in advance, best wishes.. Ozzy
Ozcan Asilkan wrote:> Hello, > > I am very new to R and Time Series. I need some help including R codes > about the following issues. I' ll really appreciate any number of > answers... > > # I have a time series data composed of 24 values: > myinput = c(n1,n2...,n24); > # In order to make a forecasting a, I use the following codes > result1 = arima(ts(myinput),order = c(p,d,q),seasonal = list(order=c(P,D,Q))) > result2 = forecast(result1,12) > plot(result2) > > Now, by using R code... > > 1) How can I determine if my data is statitonary or not ? (trend & > seasonal effects)Look at the data and watch for different kinds of instationarity (or better, if the assumptions for stationarity are fulfilled).> 2) If not, how can I make it stationary ?Depends on the kind of instationarity. "Making it stationary" might be impossible for the whole time series.> 3) Is arima() function used only on STATIONARY data ? Or does it first > determine if the data is stationary or not and makes it stationary ? > (if it is non-stationary)No, R cannot think. It just does some calculations.> 4) I tried different parameter values in arima() function, but every > parameter gave very different results :(( . I > even found & tried best.arima() function but it also gave > unsatisfactory result. So, how can I calculate the optimum arima() > parameters (p,d,q,P,D,Q) that fit my data best ?You got to the right question. Unfortunately, we are all interested in its answer. It depends on your definition on best and is not that easy. You might want to start reading on the Box-Jenkins method to determine parameters and continue to read a good textbook on time series analysis. Or just ask the oracle. Best, Uwe Ligges> Thanks in advance, best wishes.. > > Ozzy > > ______________________________________________ > R-help at 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.
With 24 values you are asking the impossible from your data. If you use the standard Box Jenkins approach rather than an automatic ARIMA and using any prior knowledge of the data you might manage some form of forecast. Look at graphs of the data and their first differences. Look at graphs of the autocorrelation and partial autocorrelation functions. There are a range of text books that describe this kind of manual Box-Jenkins approach. There is an excellent account of stationarity and related matters in Pfaff, B (2006), "Analysis of Integrated and Cointegrated Time Series with R", in the Springer USE R! series. This also contains an account of ARMA models. Best regards John On 26/11/2007, Ozcan Asilkan <oasilkan at gmail.com> wrote:> Hello, > > I am very new to R and Time Series. I need some help including R codes > about the following issues. I' ll really appreciate any number of > answers... > > # I have a time series data composed of 24 values: > myinput = c(n1,n2...,n24); > # In order to make a forecasting a, I use the following codes > result1 = arima(ts(myinput),order = c(p,d,q),seasonal = list(order=c(P,D,Q))) > result2 = forecast(result1,12) > plot(result2) > > Now, by using R code... > > 1) How can I determine if my data is statitonary or not ? (trend & > seasonal effects) > 2) If not, how can I make it stationary ? > 3) Is arima() function used only on STATIONARY data ? Or does it first > determine if the data is stationary or not and makes it stationary ? > (if it is non-stationary) > 4) I tried different parameter values in arima() function, but every > parameter gave very different results :(( . I > even found & tried best.arima() function but it also gave > unsatisfactory result. So, how can I calculate the optimum arima() > parameters (p,d,q,P,D,Q) that fit my data best ? > > Thanks in advance, best wishes.. > > Ozzy > > ______________________________________________ > R-help at 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. >-- John C Frain Trinity College Dublin Dublin 2 Ireland www.tcd.ie/Economics/staff/frainj/home.html mailto:frainj at tcd.ie mailto:frainj at gmail.com
Look at the R help files for predict.Arima rather than using forecast to forecast an ARIMA model. You might plot your data and the first difference and you should be able to come to a conclusion about stationarity. With your very small data set you need a very parsimonious model. Knowledge about the nature of the data set would also be important. I see no seasonal effect in the data and wonder why you are proposing to allow two seasonal differences. Probably some form of smoothing would be more suitable in your case. Best Regards John On 29/11/2007, Ozcan Asilkan <oasilkan at gmail.com> wrote:> Hi ohn, > > Thank you for your reply. I read in a few documents that if a Time Series > data is NONStationary, ARIMA models must be used. So, if we suppose that my > data is non-stationary, is it basically enough just to use the arima() > function in R to make a future forecast ? Does arima function implicitly > convert my data into stationary status by handling differencing, removing > seasonality, etc. ? Or must I explicitly convert my data to stationary form > in order to use arima() ? > > and here' s my code. I' ll appreciate your help making suggestions.. Thank > you very much. > > Best regards.. > Ozzy > > # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # > # Loading the library... > library(forecast) > > # my input data having 3 years of monthly data (36 data) > invec <- > c(15289,14282,16153,15885,15369,15488,15462,14697,15512,15506,15271,15111,14963,15150,15061,14896,15147,14967,15026,15102,14880,15181,14979,15300,15377,15323,15462,15422,15598,15518,15497,15593,15348,15453,15361,15361) > > # converting to TS > invecTS <- ts(invec, start = c(2005,1), frequency = 12) > > # using arima function > invecTSAR = arima(invecTS, order = c(0,1,1), seasonal = list(order = c(0, 2, > 0) ) ) > > # making a further 2 years forecasting (=24 months) > invecTSARPR <- forecast(invecTSAR,24) > > # and plotting > plot(invecTSARPR,xlab="TIME", ylab="PRICE (?)", fcol="red",plot.conf=F) > > # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # > > > On Nov 26, 2007 10:30 PM, Uwe Ligges > <ligges at statistik.uni-dortmund.de> wrote: > > > > > > > > Ozcan Asilkan wrote: > > > Hello, > > > > >-- John C Frain Trinity College Dublin Dublin 2 Ireland www.tcd.ie/Economics/staff/frainj/home.html mailto:frainj at tcd.ie mailto:frainj at gmail.com