[R] Problem auto.arima() in R

Ben Bolker bbolker at gmail.com
Thu Jun 16 16:37:16 CEST 2011


On 06/16/2011 03:04 AM, siddharth arun wrote:
> 
> I will break my query into 2 parts:
> 
>  1. My main idea is to give some data as an input and if any seasonality
> is there in the input, it should be captured automatically and the
> corresponding frequency automatically generated. please comment whether
> this is possible with auto.arima() 

  I don't know.  Based on a brief glance at the manual page, it does
seem that it handles seasonal models.  I would recommend that you look
at the Journal of Statistical Software article referenced in
?auto.arima.  It's probably also worth browsing through Chap. 14 of
Venables and Ripley "Modern Applied Statistics with S" to get background
on time series analysis in R/S.

For auto.arima(), you need to know the frequency at which the data are
sampled (and assume that you are trying to fit annual patterns).  If you
are looking for patterns of an unknown frequency, spectral analysis is
probably a more appropriate approach.
> 
> 2. If frequency has to be manually entered to capture seasonality in
> data. what do we enter if each data point corresponds to a year .


  ts(x,freq=1) ?? If each data point corresponds to a year then you
can't estimate seasonality, can you?  See ?ts.

  If (as mentioned above) you are trying to detect _periodicity_ rather
than _seasonality_ (i.e. regular patterns with an _unknown_ period) then
seasonal ARIMA is probably not the right way to go.

> 
> Below is the inbuilt data in R "AirPassengers" which captures
> seasonality automatically when we call auto.arima() for this data.
> 
>  Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
> 1949 112 118 132 129 121 135 148 148 136 119 104 118
> 1950 115 126 141 135 125 149 170 170 158 133 114 140
> 1951 145 150 178 163 172 178 199 199 184 162 146 166
> 1952 171 180 193 181 183 218 230 242 209 191 172 194
> 1953 196 196 236 235 229 243 264 272 237 211 180 201
> 1954 204 188 235 227 234 264 302 293 259 229 203 229
> 1955 242 233 267 269 270 315 364 347 312 274 237 278
> 1956 284 277 317 313 318 374 413 405 355 306 271 306
> 1957 315 301 356 348 355 422 465 467 404 347 305 336
> 1958 340 318 362 348 363 435 491 505 404 359 310 337
> 1959 360 342 406 396 420 472 548 559 463 407 362 405
> 1960 417 391 419 461 472 535 622 606 508 461 390 432
> 
> 
> But when I use data such as c(4,3,2,1,4,3,2,1,4,3,2,1) for calling
> auto.arima() it does not captures seasonality. But this data has obvious
> seasonality.
> Please comment.

  If you know that these are quarterly data, then specify it.

z <- ts(rep(4:1,3),frequency=4)

> auto.arima(z,trace=TRUE)

 ARIMA(2,0,2)(1,0,1)[4] with non-zero mean : 1e+20 *
 ARIMA(0,0,0) with non-zero mean : 40.73225
 ARIMA(1,0,0)(1,0,0)[4] with non-zero mean : 1e+20 *
 ARIMA(0,0,1)(0,0,1)[4] with non-zero mean : 1e+20
 ARIMA(0,0,0)(1,0,0)[4] with non-zero mean : 1e+20 *
 ARIMA(0,0,0)(0,0,1)[4] with non-zero mean : 1e+20
 ARIMA(0,0,0)(1,0,1)[4] with non-zero mean : 1e+20 *
 ARIMA(1,0,0) with non-zero mean : 42.69388
 ARIMA(0,0,1) with non-zero mean : 1e+20
 ARIMA(1,0,1) with non-zero mean : 1e+20
 ARIMA(0,0,0) with zero mean     : 60.23336

 Best model: ARIMA(0,0,0) with non-zero mean

Series: z
ARIMA(0,0,0) with non-zero mean

Coefficients:
      intercept
         2.5000
s.e.     0.3228

sigma^2 estimated as 1.25:  log likelihood = -18.37
AIC = 40.73   AICc = 42.07   BIC = 41.7


  auto.arima() tries to fit seasonal models, but discards them.  This
data set is probably too short and too artificial to draw conclusions
from ...

> 
> 
> On Thu, Jun 16, 2011 at 12:54 AM, Ben Bolker <bbolker at gmail.com
> <mailto:bbolker at gmail.com>> wrote:
> 
>     siddharth arun <sid.arun91 <at> gmail.com <http://gmail.com>> writes:
> 
>     >
>     > I am using auto.arima() for forecasting.When I am using any in
>     built data
>     > such as "AirPassangers" it is capturing seasonality. But, If I am
>     entering
>     > data in any other format(in vector form or from an excel sheet) it
>     is not
>     > detecting seasonality.
>     >
>     > Is there any specific format in which it detects seasonality or I
>     am doing
>     > some thing wrong?
>     >
>     > Does data have to be entered in a specific format?
>     >
> 
>     Unfortunately, this is far too vague a question for us to answer.
>     Please read the posting guide and give us some more details about
>     what you are trying to do, preferably as a small reproducible example.
>     Also, be aware that auto.arima() is a function in the
>     contributed 'forecast' package: this would be useful information to
>     include.
> 
>      Ben Bolker
> 
>     ______________________________________________
>     R-help at r-project.org <mailto: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.
> 
> 
> 
> 
> -- 
> Siddharth Arun,
> 4th Year Undergraduate student
> Industrial Engineering and Management,
> IIT Kharagpur



More information about the R-help mailing list