GARCH(1,1)のデータ生成とパラメータ推定
library(fGarch)
library(FinTS)
omega = 1e-06
alpha = 0.1
beta = 0.8
spec = garchSpec(model = list(omega, alpha, beta))
x <- garchSim(spec, n = 1000)
ts.plot(x)
res <- garchFit( formula = ~garch(1, 1), data = x )
cat(sprintf("%f %f %f\n",omega,alpha,beta))
cat(sprintf("%s\n",attributes(res)$fit$coef))
|
EACD(1,1)のデータ生成とパラメータ推定
library(fACD)
library(FinTS)
C <- array(1:1);
C$w = 0.1
C$p = 0.5
C$q = 0.3
x <- ACD_Simul(1000, C, "exp", "ACD")
ts.plot(x)
res <- ACD_Fit(x,1,1,"exp","ACD")
CC <- attributes(res)$Coeff
AIC = -2.0*attributes(res)$LL
AIC = AIC +2.0*attributes(res)$sizeModel$nParameters
cat(sprintf("%f %f %f %f\n",CC$w,CC$p,CC$q,AIC))
|
yuimaパッケージによる銘柄間の相関係数の推定
library(yuima) # define yuima calss data # x.logprcは対数価格ベクトル, x.hmsはタイムスタンプ xprc <- zoo(x.logprc,order.by=x.hms) # zoo()によって, 非等間隔時系列データを作成 yprc <- zoo(y.logprc,order.by=y.hms) # 2つの非等間隔時系列データを結合(マージ) xyprc<- merge.zoo(xprc,yprc) # setData()によって, yuimaクラスとして登録 xyprc.yuima <- setData(xyprc) # calculate correlation # PHY法, タイムスタンプは1秒単位(utime=1) cce(xyprc.yuima,method="PHY",utime=1) cce(xyprc.yuima,method="SIML",utime=1) # SIML法 cce(xyprc.yuima,method="RK",c.RK=1, utime=1) # RK法 cce(xyprc.yuima,method="TSCV",c.two=1, utime=1) # TSCV法 |
[文献]
Christensen, K., Kinnebrock, S. and Podolskij, M. (2010) "Pre-averaging estimators of the ex-post covariance matrix in noisy diffusion models with non-synchronous data", J. Econometrics, Vol. 159, pp. 116-133.
Kunitomo, N. and Sato, S. (2013) "Separating Information Maximum Likelihood estimation of the integrated volatility and covariance with micro-market noise", North Amer. J. Econ. Fin..
Barndorff-Nielsen, O. E., Hansen, P. R., Lunde, A. and Shephard, N. (2011) "Multivariate realised kernels: consistent positive semi-definite estimators of the covariation of equity prices with noise and non-synchronous trading", J. Econometrics, Vol. 162(2), pp. 149-169.
Zhang, L., Mykland, P. A. and Ait-Sahalia, Y. (2005) "A Tale of Two Time Scales: Determining Integrated Volatility with Noisy High-frequency Data", J. Amer. Statist. Assoc., Vol. 100, pp. 1394-1411.
Zhang, L. (2011) "Estimating covariation: Epps effect, microstructure noise", J. Econometrics, Vol. 160, pp. 33-47.
Kolmogorov-Smirnov検定による正規性の確認
pks <- function(x){
i<-1
cdf <- 0.0
while (1) {
d <- 2.0*exp(-2.0*(2*i-1)*(2*i-1)*x*x)
d <- d - 2.0*exp(-2.0*(2*i)*(2*i)*x*x)
if(d < 1e-16) break
cdf <- cdf + d
i <- i+1
}
cdf
}
KStest <- function(x){
x <- x[!is.na(x)]
n <- length(x)
PVAL <- NULL
sx <- sort(x)
xx <- c(1:n)
for(i in 1:n){
xx[i] <- length(sx[sx<sx[i]])/length(x)
}
y <- pnorm(sx,mean(sx),sd(sx))
D <- max(abs(y-xx)*sqrt(n))
PVAL <- pks(D)
cat(sprintf("D=%f, p=%f\n",D,PVAL))
}
x<-rnorm(300)
KStest(x)
|
α=0.05 (5%有意水準)とすると, 得られるp値が0.05以下である場合に帰無仮説H0 (2つの分布は一致する) は棄却され, 標本データが従う分布は正規分布ではないと結論付けることができる (コードを実行して読者自身で値を確かめてほしい).
(C)2016 Takaki Hayashi and Aki-Hiro Sato. All rights reserved. 無断転用を禁ず