W707 s-taiji@is.titech.ac.jp 1 / 37
TOPIX30 2 / 37
1 2 TOPIX30 3 / 37
2000 3000 4000 5000 6000 x 1992 1993 1994 1995 1996 1997 1998 Time 4 / 37
t {X t } t i.i.d. t 5 / 37
Definition ( ) {X t } t. t 1,..., t N X t1,..., X tn 6 / 37
Definition ( ) {X t } t t 1,..., t N, h X t1,..., X tn X t1 +h,..., X tn +h 7 / 37
0.3 0.2 0.1 0.0 0.1 0.2 0.3 z 0 50 100 150 Index (X t = 0.7X t + 0.1ϵ t, AR(1) ) 8 / 37
20 10 0 10 20 30 0.0 0.5 1.0 1.5 x z 0 50 100 150 200 Index 0 50 100 150 Index ( ) 8 / 37
: µ t := E[X t ] ( t) µ t t µ = µ t : γ(t, s) := Cov(X t, X s ) = E[(X t µ t )(X s µ s )] γ(t, s) t s γ(h) = γ(t, t + h) 9 / 37
( ) Definition ( ) {X t } t µ t γ(t, s) t s 10 / 37
11 / 37
1960 1970 1980 1990 : m <- decompose(co2) # co2 timeseries plot(m) # Decomposition of additive time series random 0.5 0.0 0.5 seasonal trend 3 2 1 0 1 2 3 320 330 340 350 360 observed 320 330 340 350 360 Time 12 / 37
1960 1970 1980 1990 (stl) stl decompose stllc <- stl(co2, "periodic") plot(stllc) remainder 0.5 0.0 0.5 trend 320 330 340 350 360 seasonal 3 2 1 0 1 2 3 data 320 330 340 350 360 time 13 / 37
xsmooth <- kernapply(x,kernel("daniell", 10)) # Daniell 2000 3000 4000 5000 6000 x 1992 1993 1994 1995 1996 1997 1998 Time 14 / 37
: ρ(t, s) := γ(t, s) γ(t, t)γ(s, s). t s acf(stllc$time.series[,"remainder"]) CO2 Series stllc$time.series[, "remainder"] ACF 0.2 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.5 1.0 1.5 2.0 Lag 15 / 37
acf(stllc$time.series[,"remainder"], type = "covariance") Series stllc$time.series[, "remainder"] ACF (cov) 0.02 0.00 0.02 0.04 0.06 0.0 0.5 1.0 1.5 2.0 Lag 16 / 37
AR 3 17 / 37
AR 3 AR X t = p ϕ i X t i + ϵ t. i=1 ϵ t N(0, σ 2 ) (i.i.d.). p AR 17 / 37
R AR ar(x, aic = TRUE, order.max = NULL, method = c("yule-walker", "burg", "ols", "mle", "yw"), AR AIC order.max AR method yule-walker 18 / 37
Yule-Walker X t = X t 1 ϕ 1 + + X t p ϕ p + ϵ t X t h X t = X t h X t 1 ϕ 1 + + X t h X t p ϕ p + X t h ϵ t γ(h) = γ(h 1)ϕ 1 + + γ(h p)ϕ p. ( ) Yule-Walker : γ(1) γ(0) γ(1) γ(p 1) ϕ 1 γ(2) γ(1) γ(0) γ(p 2) ϕ 2 =........ γ(p) }{{} γ(p 1) } γ(p 2) {{ γ(0) ϕ p }}{{} γ Γ ϕ γ Γ : ϕ = Γ 1 γ. 19 / 37
AR : AIC ar.co2$aic 0 50 100 150 0 5 10 15 20 25 Index > ar.co2 <- ar(stllc$time.series[,"remainder"]) > ar.co2$aic AIC 20 / 37
AR(1) X t = ϕ 1 X t 1 + ϵ t AR(1) ϕ 1 ϕ 1 1 AR 21 / 37
R Dickey-Fuller > adf.test(ukgas) Augmented Dickey-Fuller Test data: UKgas Dickey-Fuller = -1.6079, Lag order = 4, p-value = 0.7393 alternative hypothesis: stationary 22 / 37
(VAR) X t R d AR (VAR): X t = A 1 X t 1 + + A p X t p + ϵ t. A i R d d 23 / 37
R VAR AR VAR library(vars) varsel <- VARselect(tsx,lag.max=5) # var.topix <- VAR(tsx,p=varsel$selection[1]) #AIC 24 / 37
1 2 TOPIX30 25 / 37
TOPIX CORE 30 TOPIX CORE 30 30 250 (2013/6/28 2014/7/4) ( ) 26 / 37
ts(topix30[, 1:10])... 4400 4600 4800 5000... 380 420 460 500... 3000 3400 3800... 600 650 700 750 800 850......&...... 5500 6000 6500 7000 3400 3800 4200 3000 3200 3400 3600......... 2000 2200 2400 2600 280 300 320 340 1000 1100 1200 1300 0 50 100 150 200 250 Time 0 50 100 150 200 250 Time 27 / 37
: R t = log(x t /X t 1 ). 28 / 37
Series ts(logrt[, 20]) Series ts(logrt[, 1]) ACF 0.0 0.2 0.4 0.6 0.8 1.0 ACF 0.2 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 Lag UFJ 0 5 10 15 20 Lag 29 / 37
AR UFJ ufjts <- ts(logrt[,20]) # ar.ufj <- ar(ufjts) #AR 30 / 37
AIC ar.ufj$aic 0 5 10 15 20 25 30 0 5 10 15 20 0:(length(ar.ufj$aic) 1) UFJ AIC 31 / 37
AR > ar.ufj$ar #AR [1] 0.10819647 0.05554658-0.10994533-0.11853056 32 / 37
AR Normal Q Q Plot Sample Quantiles 0.04 0.02 0.00 0.02 0.04 3 2 1 0 1 2 3 Theoretical Quantiles 33 / 37
> shapiro.test(ar.ufj$resid[5:230]) Shapiro-Wilk normality test data: ar.ufj$resid[5:230] W = 0.9907, p-value = 0.1603 34 / 37
(R t > 0 R t < 0 ) 3 L1 35 / 37
tedata$y 0.0 0.2 0.4 0.6 0.8 1.0 0 10 20 30 40 Index 150 96 0.6304348 0.5 0.5 36 / 37
http://www.is.titech.ac.jp/~s-taiji/lecture/dataanalysis/dataanalysis.html 37 / 37