0.1 Simulation study based on Junmo Song and Jiwon Kang (2017)

0.1.1 The statistics of the test

The residuals are computed as follow: \[\begin{equation} \tag{1} \label{eq1} \hat{\eta}_{t}=\frac{\tilde{\epsilon}_{t}(\hat{\theta}_{n})}{\tilde{\sigma}_{t}(\hat{\theta}_{n})} \end{equation}\]

The residual-based CUSUM statistics test is defined as follow:

\[\begin{equation} \tag{2} \label{eq2} T^{R}_{n}:=\frac{1}{\sqrt{n}\hat{\tau}}\mathop {\max }\limits_{1 \le k \le n} \left| {\sum\limits_{t = 1}^k {\hat \eta_t^2} - {k \over n}\sum\limits_{t = 1}^n {\hat \eta _t^2} } \right| \end{equation}\] where

\[\hat{\tau}^{2}=\frac{1}{n}\sum^{n}_{t=1}{\hat{\eta}_t^2}-\left(\frac{1}{n}\sum^{n}_{t=1}{\hat{\eta}_t^2}\right)^{2}\tag{3}\]

0.1.2 Simulation model

I used the same simulation model as the authors: \(ARMA(1,1)-GARCH(1,1)\):

\[\begin{equation} \tag{4} \label{eq3} X_{t}-\mu=\phi\left(X_{t-1}-\mu\right)+e_{t}-\theta e_{t-1} \end{equation}\]

with \[\left\{ \matrix{ {e_t} = {\sigma _t}{\eta _t} \hfill \cr \sigma _t^2 = \omega + \alpha e_{t - 1}^2 + \beta \sigma _{t - 1}^2 \hfill \cr} \right.\tag{5}\] and \(\eta_{t}\sim \mathbf{N}(0,1)\)

0.1.3 Size computation

  1. Estimate \(\hat{\theta}\) such that
  2. :

    \[{{\hat \theta }_n} = \mathop {\arg \min }\limits_{\theta \in \Theta } {1 \over n}\sum\limits_{t = 1}^n {\left( {{{\tilde{\epsilon}^{2}_{t}(\theta)} \over {\tilde{\sigma}^{2}_{t}(\theta)}}+\log{\tilde{\sigma}^{2}_{t}(\theta)}} \right)} \tag{6}\] with \[\tilde{\sigma}_{t}(\theta)=X_{t}-c-\sum_{i=1}^{P}{a_{i}\left(X_{t-i}-c\right)}+\sum_{j=1}^{Q}{b_{j}\tilde{\epsilon}_{t-j}(\theta)}\tag{7}\] and \[\tilde{\sigma}^{2}_{t}(\theta)=\omega+\sum_{i=1}^{p}{\alpha_{i}\tilde{\epsilon}^{2}_{t-i}(\theta)}+\sum_{j=1}^{q}{\beta_{j}\tilde{\sigma}^{2}_{t-j}(\theta)}\tag{8}\]
  3. Generate the regression residuals \(\hat{\epsilon}_{t}(\hat\theta)\) and \(\hat{\sigma}_{t}(\hat\theta)\) then compute \(\hat{\eta}_{t}\)
  4. in order to calculate the test statistics: \[T^{R,0}_{n}:=\frac{1}{\sqrt{n}\hat{\tau}}\mathop {\max }\limits_{1 \le k \le n} \left| {\sum\limits_{t = 1}^k {\hat \eta_t^2} - {k \over n}\sum\limits_{t = 1}^n {\hat \eta _t^2} } \right|\tag{9}\]

  5. Form \(\hat\theta\) and \(\hat{\sigma}_{t}(\hat\theta)\) generate \(b\) simulation of \(X^{b}_{t}(\hat\theta)\) with \(\eta_{t}\sim \mathbf{N}(0,1)\) when \(t=1,..,n\).
  6. With \(X^{b}_{t}(\hat\theta)\) estimate \(\hat\theta^{b}\), \(b=1,..,B\) and compute the statistic of the test under bootstrap replication. \[T^{R,b}_{n}:=\frac{1}{\sqrt{n}\hat{\tau}_{b}}\mathop {\max }\limits_{1 \le k \le n} \left| {\sum\limits_{t = 1}^k {\hat \eta_{t,b}^2} - {k \over n}\sum\limits_{t = 1}^n {\hat \eta_{t,b}^2} } \right|\tag{10}\]
  7. with \(T^{R,b}_{n}\), \(b=1,...,B\) generate the \(p\)-value the test
  8. \[p_{b}=2\mathop{\min}\left(\frac{1}{B}\sum^{B}_{b=1}{\mathbf{1}\left(T^{R,b}_{n}\leq T^{R,b}_{n}\right)}; \frac{1}{B}\sum^{B}_{b=1}{\mathbf{1}\left(T^{R,b}_{n}> T^{R,b}_{n}\right)} \right)\tag{11}\]
  9. Repeate the steps 1, 2, 3, and 4, \(M\) times in order to compute the size of the test
  10. \[{size}=\frac{1}{M}\sum^{M}_{i=1}{p_{b,i}}\tag{12}\]

0.1.4 Implementation, Statistis of the test

TR_func<-function(eta){
  n<-length(eta)
  Tr<-sapply(1:n, function(k){
    abs(sum((eta[1:k])**2)-(k/n)*sum(eta**2))
  })
  
  tau_2<-(1/n)*sum(eta**4)-(1/n*sum(eta**2))**2
  k_max<-which.max(Tr)
  TR_n<-Tr[k_max]/(sqrt(n*tau_2))
  res<-list(TR_n=TR_n, k_max=k_max)
  return(res)
}

0.1.4.1 Size of the test with \((\mu, \phi,\theta)=(0, 0.5, 0.3)\) and \((\omega, \alpha, \beta)=(0.02, 0.1, 0.7)\)

library(xts)
library(rugarch)
library(lubridate)


pvalue_func<-function(mu, phi,theta, omega,alpha, beta, n,B, seed){
  set.seed(seed)
arma_garch_model <- ugarchspec(variance.model = list(model = "sGARCH", 
                                                     garchOrder = c(1, 1)),
                               mean.model = list(armaOrder = c(1, 1)),
                               fixed.pars = list(mu=mu, 
                                                 ar1=phi,
                                                 ma1=theta,
                                                 omega=omega,
                                                 alpha1=alpha,
                                                 beta1=beta), 
                               distribution.model = "norm")
fit <- ugarchpath(spec = arma_garch_model, n.sim = n)
X <- fit@path$seriesSim
x_spec<-ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1, 1)),
                               mean.model = list(armaOrder = c(1, 1)), distribution.model = "norm")
fit_x <- ugarchfit(spec = x_spec, data =X)
mu_0<-fit_garchdef@fit$matcoef["mu",1]
phi_0<-fit_garchdef@fit$matcoef["ar1",1]
theta_0<-fit_garchdef@fit$matcoef["ma1",1]
omega_0<-fit_garchdef@fit$matcoef["omega",1]
alpha_0<-fit_garchdef@fit$matcoef["alpha1",1]
beta_0<-fit_garchdef@fit$matcoef["beta1",1]

sigma<-fit_x@fit$sigma
epsilon<-fit_x@fit$residuals
T_list<-TR_func(epsilon/sigma)
T0<-T_list$TR_n
k0<-T_list$k_max
 cat(":    B  ")
Tb<-sapply(1:B, function(b){
  set.seed(seed+b)
 
  cat(".")
  if(b%%100==0) cat(":    ",b,"\n")
    arma_garch_model_b <- ugarchspec(variance.model = list(model = "sGARCH", 
                                                     garchOrder = c(1, 1)),
                               mean.model = list(armaOrder = c(1, 1)),
                               fixed.pars = list(mu=mu_0, 
                                                 ar1=phi_0,
                                                 ma1=theta_0,
                                                 omega=omega_0,
                                                 alpha1=alpha_0,
                                                 beta1=beta_0), 
                               distribution.model = "norm")
  
fit_b <- ugarchpath(spec = arma_garch_model_b, n.sim = n)
X_b <- fit_b@path$seriesSim
fit_x_b <- ugarchfit(spec = x_spec, data =X_b)
sigma<-fit_x@fit$sigma
epsilon<-fit_x@fit$residuals
T_list<-TR_func(epsilon/sigma)

return(T_list$TR_n)
})
pb<-2*min(mean(Tb<=T0),mean(Tb>T0) )
res<-list(pb=pb, T0=T0, Tb=Tb)
return(res)
}

###
size_function<-function(mu, phi,theta, omega,alpha, beta, n,B,seed,sim){
  p_sim<-sapply(1:sim, function(i){
    cat("sim=", i )
    
    res<-pvalue_func(mu, phi,theta, omega,alpha, beta, n,B, seed+i)
    cat("\n")
    return(res$pb)
  })
  size<-mean(p_sim)
  return(size)
}

0.1.5 Size result

mu<-0; phi<-0.5; theta<-0.3
omega<-0.02; alpha<-0.1; beta<-0.7
 B<-399; seed<-123; sim<-100

nvec<-c(100, 200, 300, 500) # 
Size<-sapply(nvec, function(j){
  size_function(mu=mu,
                phi=phi,
                theta=theta,
                omega=omega,
                alpha=alpha, 
                beta=beta, 
                n=j,
                B=B,
                seed=seed+j,
                sim=sim)
  }
  )

0.1.6 Power of the test