Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

nsdiffs

Number of differences required for a seasonally stationary series


Description

Functions to estimate the number of differences required to make a given time series stationary. nsdiffs estimates the number of seasonal differences necessary.

Usage

nsdiffs(
  x,
  alpha = 0.05,
  m = frequency(x),
  test = c("seas", "ocsb", "hegy", "ch"),
  max.D = 1,
  ...
)

Arguments

x

A univariate time series

alpha

Level of the test, possible values range from 0.01 to 0.1.

m

Deprecated. Length of seasonal period

test

Type of unit root test to use

max.D

Maximum number of seasonal differences allowed

...

Additional arguments to be passed on to the unit root test

Details

nsdiffs uses seasonal unit root tests to determine the number of seasonal differences required for time series x to be made stationary (possibly with some lag-one differencing as well).

Several different tests are available:

  • If test="seas" (default), a measure of seasonal strength is used, where differencing is selected if the seasonal strength (Wang, Smith & Hyndman, 2006) exceeds 0.64 (based on minimizing MASE when forecasting using auto.arima on M3 and M4 data).

  • If test="ch", the Canova-Hansen (1995) test is used (with null hypothesis of deterministic seasonality)

  • If test="hegy", the Hylleberg, Engle, Granger & Yoo (1990) test is used.

  • If test="ocsb", the Osborn-Chui-Smith-Birchenhall (1988) test is used (with null hypothesis that a seasonal unit root exists).

Value

An integer indicating the number of differences required for stationarity.

Author(s)

Rob J Hyndman, Slava Razbash and Mitchell O'Hara-Wild

References

Wang, X, Smith, KA, Hyndman, RJ (2006) "Characteristic-based clustering for time series data", Data Mining and Knowledge Discovery, 13(3), 335-364.

Osborn DR, Chui APL, Smith J, and Birchenhall CR (1988) "Seasonality and the order of integration for consumption", Oxford Bulletin of Economics and Statistics 50(4):361-377.

Canova F and Hansen BE (1995) "Are Seasonal Patterns Constant over Time? A Test for Seasonal Stability", Journal of Business and Economic Statistics 13(3):237-252.

Hylleberg S, Engle R, Granger C and Yoo B (1990) "Seasonal integration and cointegration.", Journal of Econometrics 44(1), pp. 215-238.

See Also

Examples

nsdiffs(AirPassengers)

forecast

Forecasting Functions for Time Series and Linear Models

v8.14
GPL-3
Authors
Rob Hyndman [aut, cre, cph] (<https://orcid.org/0000-0002-2140-5352>), George Athanasopoulos [aut], Christoph Bergmeir [aut] (<https://orcid.org/0000-0002-3665-9021>), Gabriel Caceres [aut], Leanne Chhay [aut], Mitchell O'Hara-Wild [aut] (<https://orcid.org/0000-0001-6729-7695>), Fotios Petropoulos [aut] (<https://orcid.org/0000-0003-3039-4955>), Slava Razbash [aut], Earo Wang [aut], Farah Yasmeen [aut] (<https://orcid.org/0000-0002-1479-5401>), R Core Team [ctb, cph], Ross Ihaka [ctb, cph], Daniel Reid [ctb], David Shaub [ctb], Yuan Tang [ctb] (<https://orcid.org/0000-0001-5243-233X>), Zhenyu Zhou [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.