# Cut-and-paste code below into window above and Run
#
# United States (US) Model (1950-2000)
#
# Measurement Matrix (Growth), (X+XREAL-N-L), (L+XREAL-X-N)
#
# Q N HOURS XREAL X L
#[1,] 0.4124 0.403 0.413 0.410 0.399 0.412
#[2,] -0.1464 -0.580 -0.122 0.310 0.711 -0.160
#[3,] -0.0825 -0.546 0.137 0.358 -0.466 0.575
#
# Fraction of Variance
#[1] 0.977 0.999 1.000 1.000 1.000 1.000
#
merge.forecast <- function (fx,n=1) {
x <- splice(fx$pred,fx$forecast[[n]])
colnames(x) <- seriesNames(fx$data$output)
return(x)
}
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
f <- matrix( c(1.026261160, -0.04873236, 0.04995449, 0.166789178,
0.023195483, 0.97301183, 0.06694359, 0.004293523,
-0.002685722, -0.04074830, 1.00342561, -0.006797188,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize model, uncomment next line
# f[1,1] <- 0.985822375; f[2,2] <- 1.01538263; f[3,3] <- 0.95659221
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
US_LM <- SS(F=f,H=h,K=k,z0=c(0.166789178, 0.004293523, -0.006797188, 1.0000000000),
output.names=c("US1","US2","US3"))
print(US_LM)
is.SS(US_LM)
stability(US_LM)
US_LM.data <- simulate(US_LM,sampleT=100,start=1950)
#US_LM.data <- simulate(US_LM,sampleT=20,noise=matrix(0,20,3),start=1950)
US_LM.f <- forecast(l(US_LM,US_LM.data),horizon=150)
US_LM.fx <- merge.forecast(US_LM.f)
tfplot(US_LM.f)
AIC(m <- l(US_LM,US_LM.data))
US_LMx <- SS(F=f,H=h,Q=eye(4,3),R=eye(3,3),z0=c(0.166789178, 0.004293523, -0.006797188, 1.0000000000),
output.names=c("US1","US2","US3"))
shockDecomposition(US_LMx)