You are on page 1of 35

Change detection in the variance-covariance

matrix in the VAR model

ANAR MASIMOV

VILNIUS UNIVERSITY

December 14, 2017

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


GOALS

To study and test available methods of detecting structural


break in variance-covariance matrix
Implement selected tests in R software environment as a
package

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Selected test statistics

Cumulative sum test (CUSUM)


Likelihood-ratio test (LRT)
Darling-Erdös-type test (DET)

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Hypothesis
It is assumed that data follows VAR model of order p which can be
expressed as

yt = ν + A1 yt−1 + ... + Ap yt−p + et , t ≤ T ,

where is yt is random vector with k dimensions, ν is fixed


k-dimensional vector of constants, Ai, i ∈ 1, ..., p is (k × k)
0
coefficient matrix, ut is k-dimensional noise, and E [ut ut ] is
variance-covariance matrix Σ.
The aim is to test following hypothethis
0
H0 : E [et et ] = Σ, t = p + 1, ..., h,

against
(
0 Σ, t = p + 1, ..., h
H1 : ∃h : E [et et ] = , where Σ 6= Σ̃
Σ̃, t = h + 1, ..., T

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Cumulative sum test

h 0 T 0
h et Σ−1 et et Σ−1 et
 X X
Ch = √ −
2Tk t=p+1
t t=p+1
T

where T is number of time points, et is vector of residuals at time t,


h is assumed location of the changepoint and k is number of
dimensions. When true model is unknown et and Σ are estimated
using maximum-likelihood parameters.
To estimate location of the change point the following statistic is
used
Cmax = max |Ch |,
p+1≤h≤T

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Cmax asymptotic distribution

T
Asymptotic distribution of Cmax is sup |W0t |, which allows to
compute critical values in the following way

" #
X
P |Cmax | ≤ x = 1 + 2 exp(−2i 2 x 2 )
i=1

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Likelihood-ratio test

T 0
et et
| |
P
T
t=p+1
LRh = T log h 0 T 0
et et h et et 1− h
| |T | T −h |
P P
T
t
t=1 t=t+1

Thus the change point h is assumed to be at the time point where


LRh statistics has maximal value and is denoted by LRmax .
NO ASYMPTOTIC DISTRIBUTION
LRmax has no asymptotic distribution.

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Darling-Erdös-type test

N h 0 N 0
0
b −1 ebt − b −1 eb b −1 eb
X X X
Λh = ebt Σ eb
¯t Σ ¯t − eb
˜t Σ ˜t ,
t=p+1 t=p+1 t=h+1

where eb
¯t and eb
˜t are estimated error terms of VAR(p) model fitted
on yp+1 ...yh and yh+1 ...yN respectively.
Darling-Erdös-type test
0
h−p 
Λ∗ b eb̄t eb̄t − In ]2 ,

h = Λh + κ−k 2
b
(tr (Σ h−p

where tr (·) is a trace, and


T
1 X 0 −1 
κ
b= ebt Σ
b ebt .
T t=p+1

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Λmax asymptotic distribution

Λmax = max Λh
p+1≤h≤T

Λ∗ max follows Gumbel distribution


" #
Λ∗ h − bd  x
P ≤ x −−−−−→ exp − 2e 2
ad N→
− ∞

where bd and ad are normalising constants, d = k(kp + 1) + 1


d
2
ln ln ln T − ln Γ( d2 )

2 ln ln T + 2
bd =
2 ln ln T
s
bd
ad = , d = k(kp + 1) + 1
2 ln ln T

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


VARCP package
#devtools::install_github("MasimovR/VARCP")
library(VARCP)

## Loading required package: MTS

phi <- matrix(c(0.2,-0.6,0.3,1),2,2)


sig <- matrix(c(4,0.8,0.8,1),2,2)
m1 <- VARMAsim(200, arlags = 1, phi=phi, sigma=sig)
m2 <- VARMAsim(200, arlags = 1, phi=phi, sigma=sig*2)
m <- rbind(m1$series, m2$series)
model <- VARMA(m, p = 1, q = 0)

## Number of parameters: 6
## initial estimates: 0.0327 0.0868 0.1742 0.3198 -0.6351
## Par. lower-bounds: -0.2227 -0.0349 0.0778 0.2378 -0.681
## Par. upper-bounds: 0.2882 0.2084 0.2706 0.4018 -0.5892
## Final Estimates: 0.03923484
ANAR MASIMOV 0.08684836
Change detection 0.1748575
in the variance-covariance 0.31
matrix in the VAR
statcomp

CUSUM <- statcomp(model, type = "CUSUM", trim = 10)


LRT <- statcomp(model, type = "LRT", trim = 10)
DET <- statcomp(model, type = "DARLING-ERDOS", trim = 10)
str(CUSUM)

## List of 2
## $ values: Named num [1:380] -0.266 -0.314 -0.31 -0.233
## ..- attr(*, "names")= chr [1:380] "11" "12" "13" "14"
## $ type : chr "CUSUM"
## - attr(*, "class")= chr "VARCD"

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


PLOT 1/3
plot(CUSUM, a = 0.01)
CUSUM statistic
1
0
Statistic value

−1
−2
−3

0 100 200 300 400

ANAR MASIMOV Time index detection in the variance-covariance matrix in the VAR
Change
PLOT 2/3
plot(LRT, a = 0.01)
LRT statistic
40
30
Statistic value

20
10
0

0 100 200 300 400

ANAR MASIMOV Time index detection in the variance-covariance matrix in the VAR
Change
PLOT 3/3
plot(DET, a = 0.01)
Darling−Erdös−type test statisic
10
5
Statistic value

0
−5

0 100 200 300 400

ANAR MASIMOV Time index detection in the variance-covariance matrix in the VAR
Change
changetest

changetest(CUSUM)

##
## CUSUM test
##
## data: CUSUM
## Estimated change point = 201, p-value = 8.643e-09
## sample estimates:
## C(h)
## 3.103198

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Simulation

Simulation of time series is done in R software enviroment using


MTS package. For test size analysis were done 5000 replications of
VAR(1) model with Gaussian noise for T = 200, 1000 and 5000,
zero mean and following parameters
! !
0.6 0.2 1.0 0.2
A= , Σ=
0.2 0.4 0.2 1.0

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Size of the tests

Figure 1: P value plots

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Simulation with structural change

Change point location is chosen to be at 0.15 × T , 0.5 × T and


0.85 × T . For each T and h were simulated two time series. First
one is sampled from model with paramters given in previously and
has length h. Second has length T − h and same parameters,
except for variance-covariance matrix. New variance-covariance
matrix, Σh , is one of the following
! !
1.2 0.24 1.5 0.3
Σ1 = 1.2 × Σ = , Σ2 = 1.5 × Σ =
0.24 1.2 0.3 1.5

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


h = 0.15 × T , Σh = 1.2 × Σ

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


h = 0.15 × T , Σh = 1.5 × Σ

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


h = 0.5 × T , Σh = 1.2 × Σ

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


h = 0.5 × T , Σh = 1.5 × Σ

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


h = 0.85 × T , Σh = 1.2 × Σ

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


h = 0.85 × T , Σh = 1.5 × Σ

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Median and MAD of ĥ, Σh = 1.2 × Σ
CUSUM LRT DET
Estimated change point
T h Median MAD Median MAD Median MAD
30 92 64.33 60 57.20 120 86.11

200 100 101 26.78 96 48.98 135 63.82


170 120 56.68 108 72.51 130 64.14
150 318 226.57 198 246.39 667 470.51

1000 500 501 61.18 500 171.88 740 355.12


850 831 60.87 777 284.95 764 349.47
750 961 449.29 749 234.91 3712 2508.42

5000 2500 2501 81.83 2500 112.54 3926 1923.68


4250 4108 354.19 4248 262.91 4286 1756.82
ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR
Median and MAD of ĥ, Σh = 1.5 × Σ
CUSUM LRT DET
Estimated change point
T h Median MAD Median MAD Median MAD
30 70 48.76 36 40.94 127 90.88

200 100 101 12.84 100 30.33 151 60.61


170 151 35.74 158 51.35 168 53.13
150 200 103.74 151 42.91 756 521.06

1000 500 502 17.34 501 22.16 846 358.06


850 831 60.87 850 42.98 900 268.81
750 808 157.51 751 18.86 4304 2842.74

5000 2500 2502 18.21 2501 18.62 4517 1925.66


4250 4229 78.97 4251 19.14 4721 1310.35
ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR
Data Analysis

fNIRS data from 16 optodes from 6 participants


4 variable: HbO, HbR, HbT, OXY
First control, experiment, second control

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Data preparation

Data came already detrended


Were selected only 2 optodes from left hemisphere
Using control data and BIC and AIC criterion was selected AR
order of 10

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Raw data

Figure 2: HbO values of first female participant

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


CUSUM test for seperate stages

Figure 3: CUSUM test of HbO values of first female participant

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Test statistics for all stages

Figure 4: HbO values of first female participant

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Mean absolute deviation from first change point
across participants

CUSUM LRT DET


Participant MAD MAD MAD
Female 1 15.75 10.00 3.75
Female 2 16.00 11.50 5.25
Female 3 5.25 8.75 5.00
Male 1 3.25 9.50 2.50
Male 2 6.00 10.25 3.25
Male 3 9.00 12.00 4.00

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Mean absolute deviation from second change point
across participants

CUSUM LRT DET


Participant MAD MAD MAD
Female 1 8.00 2.25 0.00
Female 2 19.00 8.25 0.75
Female 3 21.25 1.75 1.25
Male 1 0.00 2.75 1.25
Male 2 6.75 5.25 3.00
Male 3 7.00 23.75 0.00

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Mean absolute deviation from first change point
across variables

CUSUM LRT DET


Measure MAD MAD MAD
HBO 13.00 10.00 5.00
HBR 5.50 9.00 3.17
HBT 12.83 10.17 4.17
OXY 5.50 12.17 3.50

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR


Mean absolute deviation from second change point
across variables

CUSUM LRT DET


Measure MAD MAD MAD
HBO 3.83 8.33 1.67
HBR 15.83 5.50 0.67
HBT 15.17 7.83 0.50
OXY 6.50 7.67 1.33

ANAR MASIMOV Change detection in the variance-covariance matrix in the VAR

You might also like