# Cut-and-Paste Code below into Window Above and Run
#
# USHC BAU Model
#
# Measurement Matrix
# (Growth - Hospitals) (N + L + OH - Q) (Growth - N - Capital)
# P.HC. GDP.HC. N.PI. K.HC. L.HC O.H.
#[1,] 0.4324 0.432 0.339 0.4317 0.427 -0.379
#[2,] -0.0762 -0.130 0.763 -0.0865 0.210 0.586
#[3,] 0.4448 0.288 -0.466 -0.2307 0.362 0.564
#
# Fraction of Variance
#[1] 0.881 0.991 0.998 1.000 1.000 1.000
#
require(dse)
require(matlab)
AIC <- function(model) {informationTestsCalculations(model)[3]}
f <- matrix( c(1.05997234, 0.002735686, 0.03889518, 0.17280925,
-0.03298602, 0.945133060, -0.23385045, 0.02194855,
-0.01436626, 0.027867381, 1.02834689, -0.01447672,
0.000000000, 0.00000000, 0.0000000, 1.00000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To Stabilize, Uncomment Next Line
# f[1,1] <- 1; f[2,2] <- 0.898812136; f[3,3] <- 0.97794766
#
h <- eye(3,4)
k <- f[1:4,1:3,drop=FALSE]
USHC=SS(f,H=h,K=k,z0=c(0.17280925, 0.02194855, -0.01447672,
1.0000000),
output.names=c("HC1","HC2","HC3"))
print(USHC)
stability(SS(f[1:3,1:3,drop=FALSE],H=eye(3),R=eye(3),Q=eye(3)))
# tfplot(simulate(USHC,sampleT=50,start=1950))
shockDecomposition(toSSChol(USHC))
USHC.data <- simulate(USHC,sampleT=50,noise=matrix(0,50,3))
#
# RANDOM WALK MODEL (uncomment next line as above)
# USHC.data <- simulate(USHC,sampleT=50)
#
m <- l(USHC,USHC.data)
# tfplot(m)
AIC(m)
USHC.f <- forecast(m,horizon=50)
tfplot(USHC.f)