# Cut-and-Paste Code Below into Window Above and Run
#
# US_M Model (1900-2000)
#
# Measurement Matrix
# Q N HOURS XREAL X L
#[1,] 0.418 0.399 0.4181 0.409 0.391 0.414
#[2,] -0.102 -0.555 -0.0901 0.392 0.663 -0.284
#[3,] 0.484 -0.412 0.3458 0.339 -0.538 -0.268
#
# Fraction of Variance
#[1] 0.949 0.998 0.999 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.032334642, -0.01313759, 0.14133680, 0.091785548,
0.022580531, 1.03242002, 0.07029664, 0.009258674,
-0.002991271, -0.01970478, 1.02700196, -0.004054557,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize growth, uncomment the following line.
#
# f[1,1] <- f[2,2] <- f[3,3] <- 0.98
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
US_M <- SS(F=f,H=h,K=k,z0=c( 0.091785548, 0.009258674, -0.004054557, 1.0000000000),
output.names=c("US1","US2","US3"))
print(US_M)
is.SS(US_M)
stability(US_M)
#tfplot(US_M.data <- simulate(US_M,sampleT=150,start=1900))
US_M.data <- simulate(US_M,sampleT=150,noise=matrix(0,150,3),start=1900)
US_M.f <- forecast(m <- l(US_M,US_M.data),horizon=150)
tfplot(US_M.f)
AIC(m)
US_Mx <- SS(F=f,H=h,Q=eye(4,3),R=eye(3),z0=c( 0.091785548, 0.009258674, -0.004054557, 1.0000000000),
output.names=c("US1","US2","US3"))
shockDecomposition(US_Mx)
# To explore Negative Shocks, Uncomment the next line for a -1 sd shock
#shockDecomposition(US_Mx,shock=rep(-1,10))
# To create probable counterfactuals, set coefficients between LCI and UCI
#
# LCI Parameter UCI P>=T[1] P< T[1] Std. Dev.
# [1,] 1.022403 1.032335 1.044920 0.37 0.63 0.009635
# [2,] 0.016833 0.022581 0.030721 0.38 0.62 0.005279
# [3,] -0.005139 -0.002991 -0.001554 0.58 0.42 0.001403
# [4,] -0.051668 -0.013138 0.023995 0.33 0.67 0.032309
# [5,] 1.014150 1.032420 1.055952 0.30 0.70 0.017539
# [6,] -0.026039 -0.019705 -0.014005 0.63 0.37 0.004779
# [7,] -0.043130 0.141337 0.333174 0.60 0.40 0.170630
# [8,] -0.043284 0.070297 0.163875 0.75 0.25 0.082190
# [9,] 0.999037 1.027002 1.054223 0.33 0.67 0.021011
#[10,] 0.080128 0.091786 0.104725 0.53 0.47 0.011583
#[11,] 0.001436 0.009259 0.018868 0.43 0.57 0.007608
#[12,] -0.006214 -0.004055 -0.002518 0.56 0.44 0.001453
#