Professional Documents
Culture Documents
The most recent version of the package can be found at https://github.com/nickpoison/astsa/ (https://github.com/nickpoison/astsa/)
The webpages for the texts and some help on using R for time series analysis can be found at https://nickpoison.github.io/
(https://nickpoison.github.io/).
#install.packages(
# pkgs = "remotes"
#)
#remotes::install_github(
# repo = "nickpoison/astsa/astsa_build"
#)
options(
digits = 3,
scipen = 99
)
rm(
list = ls()
)
If a time series is strictly stationary, then all of the multivariate distribution functions for subsets of variables must agree with their counterparts in
the shifted set for all values of the shift parameter h.
Example:
k=1
P (x s ≤ c) = P (x t ≤ c) ∀s, t
The probability function is constant with respect to time. Furthermore if the expected value exists, it is constant with respect to time and μs = μt .
Note a random walk is not strictly stationary because the mean changes with time.
k=2
P (x s ≤ c1 , x t ≤ c2 ) = P (x s+h ≤ c1 , x t+h ≤ c2 ) ∀ time points s, t and time shift h
The autocovariance function depends only on the time difference between s and t , and not on the actual times.
the mean value function, μt , is constant and does not depend on time t , and
the autocovariance function, γ(s, t) , depends on s and t only on the difference |s − t|.
Stationarity requires regularity in the mean and autocorrelation functions so that these quantities may be estimated by averaging.
A strictly stationary time series with finite variance is also weakly stationary. The converse is not correct unless other conditions hold.
Proposition:
If a time series is Gaussian and weakly stationary, then it is also strictly stationary.
Proposition:
When a time series is weakly stationary, then
γ(t + h, t) = cov(x t+h , x t ) = cov(x h , x 0 ) = γ(h, 0) (autocovariance depends on shift, not time)
Definition 1.8
The autocovariance function of a stationary time series will be written as
Definition
The autocorrelation function (ACF) of a stationary time series will be written as
γ(t + h, t) γ(h)
ρ(h) = =
− −−−−−−−−−−−−−−−
√ γ(t + h, t + h)γ(t, t) γ(0)
0 if h ≠ 0
γ w (h) = cov(wt+h , wt ) = {
2
σw if h = 0
0 if h ≠ 0
ρ w (h) = {
1 if h = 0
White noise satisfies the conditions of weakly stationary. If the white noise variates are also normally distributed or Gaussian, the series is also
strictly stationary, as can be seen by the fact that the noise would also be iid.
set.seed(
seed = 823
)
v_rnorm <- rnorm(
n = 10000
)
astsa::acf1(
series = v_rnorm
)
## [1] -0.01 0.00 -0.01 -0.01 0.00 -0.02 -0.01 -0.02 0.00 0.01 0.00 0.00
## [13] 0.01 0.00 0.01 -0.02 -0.01 0.00 0.01 0.00 0.01 -0.01 -0.01 0.01
## [25] 0.01 0.01 0.00 0.02 0.01 0.00 0.01 0.00 -0.02 -0.01 -0.02 0.00
## [37] 0.01 0.00 0.01 0.00 0.00 -0.01 0.01 0.00 0.00 0.00 -0.01 -0.01
## [49] 0.00 0.01 0.00 0.00 0.01 0.00 0.00 0.01 -0.01 -0.01 0.00 0.00
## [61] -0.01 0.01 -0.01 -0.01 -0.01 0.01 0.00 0.02 0.00 0.01 0.01 0.00
## [73] -0.01 0.00 0.02 -0.01 0.00 0.01 0.01 0.01 -0.02 0.00 0.01 -0.01
## [85] -0.01 0.02 -0.01 0.01 0.00 0.00 -0.01 0.00 0.01 -0.01 0.00 -0.01
## [97] -0.01 -0.01 0.02 0.01 0.00 0.00 -0.01 0.00 0.01 0.01 0.00 0.00
## [109] 0.00 -0.01
astsa::acf2(
series = v_rnorm
)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
## ACF -0.01 0 -0.01 -0.01 0 -0.02 -0.01 -0.02 0 0.01 0 0 0.01
## PACF -0.01 0 -0.01 -0.01 0 -0.02 -0.01 -0.02 0 0.01 0 0 0.01
## [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
## ACF 0 0.01 -0.02 -0.01 0 0.01 0 0.01 -0.01 -0.01 0.01 0.01
## PACF 0 0.01 -0.02 -0.01 0 0.01 0 0.01 -0.01 -0.01 0.01 0.01
## [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
## ACF 0.01 0 0.02 0.01 0 0.01 0 -0.02 -0.01 -0.02 0 0.01
## PACF 0.01 0 0.02 0.01 0 0.02 0 -0.02 -0.01 -0.02 0 0.01
## [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
## ACF 0 0.01 0 0 -0.01 0.01 0 0 0 -0.01 -0.01 0
## PACF 0 0.01 0 0 -0.01 0.01 0 0 0 -0.01 -0.01 0
## [,50] [,51] [,52] [,53] [,54] [,55] [,56] [,57] [,58] [,59] [,60] [,61]
## ACF 0.01 0 0 0.01 0 0 0.01 -0.01 -0.01 0.00 0 -0.01
## PACF 0.01 0 0 0.01 0 0 0.01 -0.01 -0.01 0.01 0 -0.01
## [,62] [,63] [,64] [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72] [,73]
## ACF 0.01 -0.01 -0.01 -0.01 0.01 0 0.02 0.00 0.01 0.01 0 -0.01
## PACF 0.01 -0.01 -0.01 -0.01 0.01 0 0.02 0.01 0.01 0.01 0 0.00
## [,74] [,75] [,76] [,77] [,78] [,79] [,80] [,81] [,82] [,83] [,84] [,85]
## ACF 0 0.02 -0.01 0 0.01 0.01 0.01 -0.02 0 0.01 -0.01 -0.01
## PACF 0 0.02 -0.01 0 0.01 0.01 0.01 -0.02 0 0.01 -0.01 -0.01
## [,86] [,87] [,88] [,89] [,90] [,91] [,92] [,93] [,94] [,95] [,96] [,97]
## ACF 0.02 -0.01 0.01 0.00 0 -0.01 0 0.01 -0.01 0 -0.01 -0.01
## PACF 0.02 -0.01 0.01 0.01 0 -0.01 0 0.01 -0.01 0 -0.01 -0.01
## [,98] [,99] [,100] [,101] [,102] [,103] [,104] [,105] [,106] [,107] [,108]
## ACF -0.01 0.02 0.01 0 0 -0.01 0 0.01 0.01 0 0.00
## PACF -0.02 0.01 0.01 0 0 -0.01 0 0.01 0.01 0 0.01
## [,109] [,110]
## ACF 0 -0.01
## PACF 0 -0.01
2
wt ∼ iidN (0, σ w )
wt−1 + wt + wt−1
vt =
3
μvt = 0
⎧
⎪
⎪
⎪ 1
⎪
⎪ 2
⎪
⎪ σw when h = −2
⎪
⎪
⎪ 9
⎪
⎪
⎪ 2
⎪
⎪
2
σw when h = −1
⎪
⎪
⎪ 9
⎪
3
2
γ v (h) =⎨ σw when h = 0
⎪ 9
⎪
⎪
⎪ 2
⎪
⎪ 2
⎪ σw when h = 1
⎪
⎪
⎪ 9
⎪
⎪
⎪ 1
⎪ 2
σw when h = 2
⎪
⎪
⎪
⎪ 9
⎩
⎪
0 when |h| > 2
⎧
⎪
⎪
⎪ 1
⎪
⎪
⎪
⎪ when h = −2
⎪
⎪
⎪ 9
⎪
⎪
⎪ 2
⎪
⎪ when h = −1
⎪
⎪
⎪ 9
⎪
3
ρ v (h) =⎨ when h = 0
⎪ 9
⎪
⎪
⎪ 2
⎪
⎪
⎪ when h = 1
⎪
⎪
⎪ 9
⎪
⎪
⎪ 1
⎪ when h = 2
⎪
⎪
⎪
⎪ 9
⎩
⎪
0 when |h| > 2
v_rnorm = rnorm(
n = 10000,
mean = 0,
sd = 1
)
filter_rnorm = filter(
x = v_rnorm,
sides = 2,
filter = rep(
x = 1/3,
times = 3
)
)
astsa::acf1(
series = filter_rnorm
)
## [1] 0.67 0.34 0.01 0.02 0.03 0.03 0.02 0.01 0.01 0.01 0.02 0.02
## [13] 0.01 0.00 -0.01 0.00 0.01 0.01 0.00 -0.01 0.00 0.00 0.01 0.02
## [25] 0.01 0.01 0.00 0.00 0.00 0.01 0.01 0.00 0.00 0.00 0.00 -0.01
## [37] -0.01 -0.01 0.00 0.01 0.02 0.03 0.02 0.01 0.00 0.00 0.00 0.01
## [49] 0.00 0.01 0.01 0.02 0.02 0.01 0.00 -0.01 0.00 0.00 0.01 0.00
## [61] 0.00 -0.01 -0.02 -0.01 0.00 0.01 0.01 0.01 0.00 0.00 0.00 0.01
## [73] 0.01 0.01 0.01 0.00 -0.01 0.00 0.01 0.02 0.01 0.00 -0.01 0.00
## [85] 0.00 0.01 0.01 0.02 0.01 0.01 0.01 0.00 0.00 -0.01 0.00 0.02
## [97] 0.03 0.03 0.02 0.01 0.00 0.00 0.00 -0.02 -0.02 -0.04 -0.03 -0.03
## [109] -0.01 -0.01
astsa::acf2(
series = filter_rnorm
)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
## ACF 0.67 0.34 0.01 0.02 0.03 0.03 0.02 0.01 0.01 0.01 0.02 0.02 0.01
## PACF 0.67 -0.20 -0.24 0.35 -0.12 -0.14 0.22 -0.10 -0.08 0.16 -0.06 -0.08 0.13
## [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
## ACF 0.00 -0.01 0.00 0.01 0.01 0.0 -0.01 0.00 0.00 0.01 0.02 0.01
## PACF -0.06 -0.06 0.12 -0.05 -0.06 0.1 -0.05 -0.03 0.08 -0.03 -0.03 0.06
## [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
## ACF 0.01 0.00 0.00 0.00 0.01 0.01 0.00 0.00 0.00 0.00 -0.01 -0.01
## PACF -0.03 -0.04 0.08 -0.03 -0.04 0.06 -0.03 -0.03 0.05 -0.04 -0.02 0.05
## [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
## ACF -0.01 0.00 0.01 0.02 0.03 0.02 0.01 0.00 0.00 0.00 0.01 0.00
## PACF -0.02 -0.01 0.06 -0.02 -0.01 0.03 -0.02 -0.02 0.05 -0.03 -0.01 0.04
## [,50] [,51] [,52] [,53] [,54] [,55] [,56] [,57] [,58] [,59] [,60] [,61]
## ACF 0.01 0.01 0.02 0.02 0.01 0.00 -0.01 0.00 0.00 0.01 0.00 0.00
## PACF -0.01 -0.01 0.05 -0.03 -0.03 0.04 -0.01 -0.01 0.03 -0.01 -0.02 0.01
## [,62] [,63] [,64] [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72] [,73]
## ACF -0.01 -0.02 -0.01 0.00 0.01 0.01 0.01 0.00 0.00 0 0.01 0.01
## PACF -0.02 -0.01 0.04 -0.01 -0.02 0.03 -0.01 -0.03 0.04 0 -0.02 0.03
## [,74] [,75] [,76] [,77] [,78] [,79] [,80] [,81] [,82] [,83] [,84] [,85]
## ACF 0.01 0.01 0.00 -0.01 0.00 0.01 0.02 0.01 0.00 -0.01 0.00 0.00
## PACF 0.00 -0.02 0.02 -0.01 0.01 0.01 0.00 -0.02 0.03 -0.03 0.01 0.01
## [,86] [,87] [,88] [,89] [,90] [,91] [,92] [,93] [,94] [,95] [,96] [,97]
## ACF 0.01 0.01 0.02 0.01 0.01 0.01 0.00 0 -0.01 0 0.02 0.03
## PACF 0.00 0.00 0.02 -0.02 0.00 0.02 -0.03 0 0.02 0 0.00 0.03
## [,98] [,99] [,100] [,101] [,102] [,103] [,104] [,105] [,106] [,107] [,108]
## ACF 0.03 0.02 0.01 0.00 0.00 0.00 -0.02 -0.02 -0.04 -0.03 -0.03
## PACF -0.01 -0.01 0.02 -0.01 -0.02 0.03 -0.04 -0.01 0.01 -0.01 -0.02
## [,109] [,110]
## ACF -0.01 -0.01
## PACF 0.02 -0.01
2
γ(s, t) = min(s, t)σ w
A random walk with drift is not stationary because the mean is a function on t
μxt = δt
set.seed(
seed = 823
)
v_rnorm = rnorm(
n = 100000
)
cumsum_rnorm = cumsum(
x = v_rnorm
) # two commands in one line
wd = v_rnorm + 0.2;
v_randomwalkdrift = cumsum(
x = wd
)
astsa::acf1(
series = cumsum_rnorm
)
## [1] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [16] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [31] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [46] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [61] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [76] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [91] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [106] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [121] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [136] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [151] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [166] 1.00 1.00 1.00 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [181] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [196] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [211] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [226] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [241] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [256] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [271] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [286] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [301] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [316] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
astsa::acf1(
series = v_randomwalkdrift
)
## [1] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [16] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [31] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [46] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [61] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [76] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [91] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [106] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [121] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [136] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## [151] 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.99
## [166] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [181] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [196] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [211] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [226] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [241] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [256] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [271] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [286] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [301] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
## [316] 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99
x t = α + βt + yt
yt is stationary
μx,t = E(x t ) = α + βt + μy
=γ y (h)
data(
list = "chicken",
package = "astsa"
)
astsa::trend(
series = chicken,
lwd = 2
)
##
## Call:
## lm(formula = chicken ~ time(chicken))
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.741 -3.473 0.825 2.774 11.580
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -7131.0225 162.4134 -43.9 <0.0000000000000002 ***
## time(chicken) 3.5921 0.0808 44.4 <0.0000000000000002 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.7 on 178 degrees of freedom
## Multiple R-squared: 0.917, Adjusted R-squared: 0.917
## F-statistic: 1.97e+03 on 1 and 178 DF, p-value: <0.0000000000000002
astsa::tsplot(
x = chicken,
ylab = "cents per pound",
col = 4,
lwd = 2
)
abline(
reg = lm_chicken
)
Properties of autocovariance
The autocovariance function of a stationary process has several special properties.
non-negative definite
bounded by the variance
symmetric about the origin
n n
0 ≤ var(a1 x 1 + … + an x n ) = ∑ ∑ aj ak γ(j − k) ∀n ∈ Z
j=1 k=1
γ(h) = γ(−h)
Two time series, say, x t and yt , are said to be jointly stationary if they are each stationary, and the cross-covariance function is a function only on
the lag h.
Definition 1.11
The cross-correlation function (CCF) of jointly stationary time series x t and yt is defined as
γ xy (h)
ρ xy (h) = and
−−−−−−−−
√ γ x (0)γ y (0)
− 1 ≤ ρ xy (h) ≤ 1
In general, cov(x 2 , y1 ) ≠ cov(x 1 , y2 ) and ρxy (h) ≠ ρ xy (−h) , but when we switch the subscript order
ρ xy (h) = ρ yx (−h)
x t = wt + wt−1
yt = wt − wt−1
wt are independent
E(wt ) = 0
2
var(wt ) = σ w
2
γ x (0) =γ y (0) = 2σ w
2
γ x (1) =γ x (−1) = σ x
2
γ y (1) =γ y (−1) = −σ x
2
γ xy (1) =cov(x t+1 , yt ) = cov(wt+1 + wt , wt = wt−1 ) = σ w (only one term in the expansion is non-zero)
⎧
⎪
⎪
⎪
⎪
⎪ −1/2 when h = −1
ρ v (h) =⎨ 0 when h = 0
⎪
⎪
⎪ 1/2 when h = 1
⎪
⎩
⎪
0 when |h| > 1
set.seed(
seed = 823
)
n <- 10000
v_rnorm <- rnorm(
n = n
)
x <- v_rnorm[-n] + v_rnorm[-1]
y <- v_rnorm[-n] - v_rnorm[-1]
var(
x = data.frame(
x = x,
y = y
)
)
## x y
## x 1.9784034 0.0000889
## y 0.0000889 2.0187481
# the acf1() plots show correlation, the variance of 2 give correlation = 1/2
astsa::acf1(
series = x
)
## [1] 0.49 -0.02 -0.02 -0.01 -0.01 -0.03 -0.03 -0.02 0.00 0.01 0.01 0.01
## [13] 0.01 0.00 0.00 -0.02 -0.02 0.00 0.01 0.00 0.00 -0.01 -0.01 0.01
## [25] 0.02 0.01 0.01 0.02 0.02 0.01 0.01 0.00 -0.02 -0.03 -0.03 -0.01
## [37] 0.00 0.00 0.01 0.00 -0.01 -0.01 0.00 0.01 0.00 0.00 -0.01 -0.02
## [49] 0.00 0.01 0.00 0.00 0.01 0.00 0.00 0.00 -0.01 -0.02 0.00 0.00
## [61] 0.00 0.00 -0.01 -0.02 -0.01 0.00 0.01 0.02 0.02 0.02 0.02 0.00
## [73] -0.01 0.00 0.01 0.00 0.00 0.01 0.02 0.01 -0.01 0.00 0.01 -0.01
## [85] -0.01 0.01 0.00 0.00 0.01 0.00 -0.01 -0.01 0.00 -0.01 -0.01 -0.01
## [97] -0.02 -0.01 0.02 0.02 0.00 -0.01 -0.02 0.00 0.01 0.01 0.01 0.01
## [109] 0.00 -0.01
astsa::acf1(
series = y
)
## [1] -0.50 0.01 -0.01 0.00 0.01 -0.01 0.00 -0.01 0.01 0.01 0.00 0.00
## [13] 0.01 -0.01 0.03 -0.02 0.00 0.00 0.01 -0.01 0.02 -0.01 -0.01 0.02
## [25] 0.00 0.00 -0.01 0.01 0.00 -0.01 0.02 0.00 -0.01 0.01 -0.01 0.00
## [37] 0.01 -0.01 0.01 -0.01 0.01 -0.02 0.02 -0.01 0.00 0.00 0.00 -0.01
## [49] 0.00 0.01 -0.01 -0.01 0.01 -0.01 -0.01 0.02 -0.01 -0.01 0.01 0.00
## [61] -0.01 0.01 -0.01 0.00 -0.01 0.02 -0.02 0.02 -0.01 0.01 0.00 0.00
## [73] -0.01 -0.01 0.02 -0.02 0.00 0.00 0.00 0.01 -0.02 0.01 0.02 -0.01
## [85] -0.01 0.02 -0.02 0.01 0.00 0.01 -0.02 0.00 0.01 -0.01 0.01 0.00
## [97] 0.00 -0.02 0.02 0.00 -0.01 0.00 -0.01 0.00 0.01 0.00 0.00 0.00
## [109] 0.00 0.00
astsa::ccf2(
x = x,
y = y,
type = "covariance"
)
yt = Ax t−l + wt
holds, then
The analysis of leading and lagging relations might be important in predicting the value of yt from x t .
Assuming that the noise wt is uncorrelated with x t , the cross-covariance function can be computed as
γ yx (h) =cov(yt+h , x t )
=cov(Ax t+h−l , x t )
=Aγ x (h − l)
By (Cauchy–Schwarz) the largest absolute value of autocovariance/autocorrelation is with lag of zero (h = l ). The cross-covariance function will
look like the autocovariance of the input series x t , and it will have
set.seed(
seed = 823
)
x = rnorm(
n = 100
)
# l = 5
y = lag(x = x,k = -5) + rnorm(n = 100)
astsa::ccf2(
x = y,
y = x,
ylab = 'Cross correlation',
type = "correlation"
)
text(
x = 9,
y = 1.1,
labels = 'x leads'
)
text(
x = -8,
y = 1.1,
labels = 'y leads'
)
astsa::ccf2(
x = y,
y = x,
ylab = 'Cross covariance',
type = 'covariance'
)
text(
x = 9,
y = 1.1,
labels = 'x leads'
)
text(
x = -8,
y = 1.1,
labels = 'y leads'
)
Weak stationarity forms the basis for much of time series analysis. The fundamental properties of the mean and autocovariance functions are
satisfied by many models that appear to generate plausible sample realizations.
The three points moving average example is an example of weakly stationary linear process.
xt = μ + ∑ ψj wt−j
j=−∞
j=−∞
2
γ x (h) = σ w ∑ ψj+h ψj
j=−∞
1
In the moving average example ψ−1 = ψ0 = ψ1 = , ψj = 0 j ≠ −1, 0, 1 .
3
When a linear process is dependent on future values, it is useless for prediction. A causal linear process has coefficient zero for future values.
An important case in which a weakly stationary series is also strictly stationary is the normal or Gaussian series.
T
x = (x t , x t , … , x t ) ,
1 2 n
for every collection of distinct time points t1 , t2 , … , tn , and every positive integer n, have a multivariate normal distribution.
T
E(x) = μ = (μt , μt , … , μt )
1 2 n
1 1 −1 T −1 n
f (x) = exp ( (x − μ) Γ (x − μ)) ∀x ∈ R
−n/2
− −
−
(2π) √ |Γ| 2
μt is constant and
γ(ti , tj ) = γ(|ti − tj |)
A linear process need not be Gaussian, but if a time series is Gaussian, then it is a causal linear process with wt 2
∼ iidnormal(0, σ w ) . Hence
stationary Gaussian processes form a basis for modeling many time series.
It is not enough for the marginal distributions to be Gaussian for the process to be Gaussian.
Counter-example:
Let X and Z be independent normal and let
Z if XZ > 0
Y = {
−Z if XZ ≤ 0