Additive Model can be written as \[ Y_t = T_t + X_t, \] where \(X_t\) is stationary time series. The trend \(T_t\) may be determinisitc, or random.
Multiplicative Model is \[ Y_t = T_t \cdot X_t. \]
If you take log() of multiplicative model, it becomes additive model.
# Montly av. residential gas usage Iowa (cubic feet)*100 ’71 – ’79
D <- read.csv("https://nmimoto.github.io/datasets/gas2.csv", header=T)
Gas2 <- ts(D[,2], start=c(1, 1), freq=12)
plot(Gas2, type='o')
##
## Call:
## lm(formula = Y ~ t)
##
## Residuals:
## Min 1Q Median 3Q Max
## -104.42 -73.56 -32.02 71.61 166.82
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 150.8356 16.2771 9.267 2.92e-15 ***
## t -0.4884 0.2641 -1.849 0.0673 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 83.2 on 104 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.03183, Adjusted R-squared: 0.02252
## F-statistic: 3.42 on 1 and 104 DF, p-value: 0.06727
We try to model the random trend with Random Walk.
Is a leading candidate to model random trend. Let \(\epsilon_t \sim_{i.i.d.} N(\mu, \sigma)\). Then \[ X_t = \sum_{i=1}^t \epsilon_{i} \] is called Random Walk.
set.seed(135) # set seed
ep = rnorm(100,0,1) # RS from N(0,1)
X = cumsum(ep) # Y is mu + random noise
plot(X, type="o")
What is the mean and variance of Random Walk?
\[
E(X_t) = E \Big( \sum_{i=1}^t \epsilon_i\Big) = \sum_{i=1}^t E(\epsilon_i) = \sum_{i=1}^n 0 = 0
\]
\[ V(X_t) = V \Big( \sum_{i=1}^t \epsilon_i \Big) = \sum_{i=1}^t V(\epsilon_i) = \sum_{i=1}^t 1 = t \]
Variance of RW grows liniarly with time
SD of Random Walk grows as \(\sqrt t\)
Therefore Random Walk is non-stationary
set.seed(5523)
ep = rnorm(100,0,1) # RS from N(0,1)
X = cumsum(ep) # X is Random Walk
plot(X, type="l", ylim=c(-34, 34))
for (i in 1:200){
ep = rnorm(100,0,1)
X = cumsum(ep)
lines(X)
}
What is mean and SD of \(X_{80}\)?
# The Dow Jones Utilities Index, Aug. 28–Dec. 18, 1972;
# DOWJ.TSM from Brockwell and Davis (2002)
D <- read.csv("https://nmimoto.github.io/datasets/dowj.csv")
D1 <- ts(D, start=c(1,1), freq=1)
plot(D1, type='o')
#[djao2]-----------------------------------------------------------------------
# Closing values of the DowJones Index of stocks on the New York Stock Exchange
# 251 successive trading days Sep 10, 1993 to Aug 26, 1994
# djao2.tsm From Brockwell and Davis (2002)
D <- read.table("https://nmimoto.github.io/datasets/djao2.csv", header=T)
D2 <- ts(D$DJ, start=c(1,1), freq=1)
plot(D2, type='o')