시계열을 만드는 데 사용하는 코드는 다음과 같습니다.
#Violent Crimes Time Series
violent <- crime[,1]
viol.ts <- ts(violent, start=1960, end=2013, frequency=1)
viol.train <- window(viol.ts, start=1960, end=2003)
viol.test <- window(viol.ts, start=2004)
ts.plot(viol.ts, type="l", xlab="Year", ylab="Total Crimes", main="Violent Crime, 1960-2013")
GARCH 모델을 추정하는 데 사용하는 코드는 다음과 같습니다.
#GARCH
viol.g <- garchFit(~arma(1,1) + garch(1,1), viol.ts)
summary(viol.g)
plot(viol.g)
plot([email protected], type="l")
plot (viol.g@fitted, type="l")
계속 오류가 발생합니다.
Error in solve.default(fit$hessian) : system is computationally singular: reciprocal condition number = 3.27071e-20
무엇이 잘못되고 있는지 전혀 모릅니다.
system is computationally singular
매개 변수 ( fit$hessian
) 에 대한 로그 우도의 이차 도함수의 역을 구할 수 없음을 의미합니다 . MLE는 로그 우도 함수를 최소화하는 매개 변수를 추정하지만,이 함수가 없으면 2 차 조건을 충족 할 수 없습니다. 이것은 이론상이며 패키지의 실제 구현이 다를 수 있습니다.
랜덤 샘플을 사용하면 아래와 같이 함수가 문제없이 작동하며 데이터를 확인할 수 있습니다.
library(fGarch)
#Violent Crimes Time Series
set.seed(1237)
violent <- sample(log(10:30), 53, replace = TRUE)
viol.ts <- ts(violent, start=1960, end=2013, frequency=1)
viol.train <- window(viol.ts, start=1960, end=2003)
viol.test <- window(viol.ts, start=2004)
ts.plot(viol.ts, type="l", xlab="Year", ylab="Total Crimes", main="Violent Crime, 1960-2013")
#GARCH
viol.g <- garchFit(~arma(1,1) + garch(1,1), viol.ts)
summary(viol.g)
plot(viol.g)
plot([email protected], type="l")
plot (viol.g@fitted, type="l")
Title:
GARCH Modelling
Call:
garchFit(formula = ~arma(1, 1) + garch(1, 1), data = viol.ts)
Mean and Variance Equation:
data ~ arma(1, 1) + garch(1, 1)
<environment: 0x0000000030109de0>
[data = viol.ts]
Conditional Distribution:
norm
Coefficient(s):
mu ar1 ma1 omega alpha1 beta1
5.42739444 -0.83160492 0.90173149 0.06406353 0.00000001 0.39089064
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다