# Cut-and-Paste Code Below into Window Above and Run
#
# US18 BAU Model United States
#
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)
#
# Measurement Matrix # overall-XREAL, Q-N-XREAL, Growth Cycles
# Q N XREAL
#[1,] 0.585 0.527 -0.616
#[2,] 0.526 -0.825 -0.206
#[3,] 0.617 0.203 0.760
#
# Fraction of Variance
#[1] 0.861 1.000 1.000
#
f <- matrix( c( 1.0104351906, 0.001202074, -0.001774616, 0.055307477,
-0.031265329, 1.018101812, -0.099887074, -0.006277844,
-0.0000170407, 0.005885763, 0.971462997, -0.001750443,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To Stabilize, Uncomment next line
# f[1,1] <- f[2,2] <- 0.90
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
US18 <- SS(F=f,H=h,K=k,z0=c(0.055307477, -0.006277844, -0.001750443, 1.0000000000),
output.names=c("US1","US2","US3"))
print(US18)
is.SS(US18)
stability(m <- SS(F=f[1:3,1:3,drop=FALSE],Q=eye(3),R=eye(3),H=eye(3)))
# tfplot(simulate(US18,sampleT=100))
US18.data <- simulate(US18,sampleT=100,noise=matrix(0,100,3),start=1700)
US18.f <- forecast(l(US18,US18.data),horizon=150)
tfplot(US18.f)
AIC(l(US18,US18.data))
shockDecomposition(m)