From Aug. 28 to Dec. 18, 1972 (Brockwell p.153)
= read.csv("https://nmimoto.github.io/datasets/dowj.csv", header=TRUE)
D = ts(D, start=1, freq=1) # turn D into TS object
Dowj plot(Dowj, type="o") # plot with both line and circle
Is this stationary?
Annual Level of Lake Huron 1875-1972
= read.csv("https://nmimoto.github.io/datasets/lake.csv", header=TRUE)
D = ts(D[,1], start=1875,, freq=1) # turn it into TS object startng year 1875
Lake plot(Lake, type="o")
Is this stationary?
How do you check if a time seirs is stationary?
Visual inspection for constant mean, constant variance
KPSS test (\(H_0\): Stationary)
ADF test (\(H_0\): Not Stationary)
PP test (\(H_0\): Not Stationary)
Fit AR(1), and see if \(\hat
\phi_1\) is significantly different from 1.
Kwiatkowski-Phillips-Schmidt-Shin (1992) test for \[
\left\{
\begin{array}{ll}
H_0: X_t \mbox{ is trend stationary}\\
H_A: X_t \mbox{ is not stationary} \\
\end{array} \right.
\] Large p-value means “Stationary”. This is default choice in
auto.arima(). Decompose the series as \[
X_t \hspace{3mm} = \hspace{3mm} T_t + W_t + Y_t
\] where \(T_t\) is
deterministic trend, \(W_t\) is random
walk, and \(Y_t\) is stationary error.
Lagrange multiplier test that the random walk has zero variance.
Augumented Dickey-Fuller test (Brockwell p. 194). “Unit-root” test for \[ \left\{ \begin{array}{ll} H_0: Y_t \mbox{ is not stationary} \\ H_A: Y_t \mbox{ is stationary} \end{array} \right. \]
Is replaced by \[ \left\{ \begin{array}{ll} H_0: Y_t \mbox{ has unit root} \\ H_A: Y_t \mbox{ does not have unit root } \end{array} \right. \]
Small p-value rejects the null hypothesis of non-stationarity, and means “Stationary”.
Fit AR(1) to a time series, and test if \(\phi_1\) is significantly different from 1,
by \[
\frac{ \hat \phi_1 -1 }{ SE(\hat \phi_1) } \sim N(0,1)
\]
Phillips-Perron test for the null hypothesis that x has a unit root. Same hypothesis as ADF test.
Small p-value means “Stationary”.
The tests are similar to ADF tests, but they incorporate an automatic correction to the DF procedure to all ow for autocorrelated residuals.
Calculation of the test statistics is complex. The tests usually give the same conclusions as the ADF tests
P-value of (KPSS, ADF, PP) tests
(LARGE, small, small) \(\to\) All three indicating stationarity.
(small, LARGE, LARGE) \(\to\) All three indicating non-stationarity.
(anything else) \(\to\) Conflicing conclusions, inconclusive.
# load Stationarity.tests() from class web page
source('https://nmimoto.github.io/R/TS-00.txt')
# Test it on random sample
= rnorm(100)
X plot(X, type="o")
Stationarity.tests(X)
## Warning in adf.test(A): p-value smaller than printed p-value
## Warning in pp.test(A): p-value smaller than printed p-value
## Warning in kpss.test(A): p-value greater than printed p-value
## KPSS ADF PP
## p-val: 0.1 0.01 0.01
Large, small, small \(\to\)
stationary. As it should be.
plot(Dowj, type="o")
Stationarity.tests(Dowj)
## Warning in kpss.test(A): p-value smaller than printed p-value
## KPSS ADF PP
## p-val: 0.01 0.655 0.847
small, Large, Large \(\to\) Not
stationary.
plot(Lake, type="o")
Stationarity.tests(Lake)
## Warning in kpss.test(A): p-value smaller than printed p-value
## KPSS ADF PP
## p-val: 0.01 0.24 0.025
small, Large, small \(\to\)
conflicting. First two is indicating Non-Stationarity, last one is
indicating stationarity.
= read.csv("https://nmimoto.github.io/datasets/steel.csv")
D
= ts(D[,2], start=c(1956,1), freq=12)
D1 plot(D1, type="o")
Stationarity.tests(D1)
## Warning in pp.test(A): p-value smaller than printed p-value
## Warning in kpss.test(A): p-value smaller than printed p-value
## KPSS ADF PP
## p-val: 0.01 0.408 0.01
= window(D1, start=c(1969, 12))
D2 plot(D2, type="o")
Stationarity.tests(D2)
## Warning in pp.test(A): p-value smaller than printed p-value
## Warning in pp.test(A): p-value smaller than printed p-value
## KPSS ADF PP
## p-val: 0.01 0.049 0.01
= window(D2, end=c(1981, 12)) # Dec 1969 to Dec 1981
D4 plot(D4)
Stationarity.tests(D4)
## Warning in adf.test(A): p-value smaller than printed p-value
## Warning in pp.test(A): p-value smaller than printed p-value
## Warning in kpss.test(A): p-value smaller than printed p-value
## KPSS ADF PP
## p-val: 0.01 0.01 0.01
= window(D2, start=c(1984, 1)) # Feb 1984 to Nov 1993
D5 plot(D5)
Stationarity.tests(D5)
## Warning in pp.test(A): p-value smaller than printed p-value
## Warning in kpss.test(A): p-value greater than printed p-value
## KPSS ADF PP
## p-val: 0.1 0.046 0.01
Three popular test for stationarity is KPSS, ADF, and PP test.
Tests are availabe in R, can be implemented with below command.
source('https://nmimoto.github.io/R/TS-00.txt')
Stationarity.tests(X)
p-value of (Large, Small, Small) indicates stationarity.
p-value of (small, Large, Large) indicates non-stationairty.