# Cut-and-Paste Code Below into Window above and Run
#
# WE_M Model (1900-2000)
#
# Measurement Matrix
# Q N U HOURS XREAL X L
#[1,] 0.392 0.391 0.386 -0.357 0.3751 0.348 0.3941
#[2,] 0.150 -0.243 -0.313 0.526 0.4252 0.599 -0.0591
#[3,] -0.402 -0.235 0.122 -0.564 0.0747 0.464 -0.4785
#
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.019119987, -0.008500298, -0.005688169, 0.088538918,
0.021974985, 1.019100181, -0.039619111, 0.009647611,
0.008570585, 0.028375621, 1.026266523, 0.006815983,
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])
WE_M <- SS(F=f,H=h,K=k,z0=c( 0.088538918, 0.009647611, 0.006815983, 1.0000000000),
output.names=c("WE1","WE2","WE3"))
print(WE_M)
is.SS(WE_M)
stability(WE_M)
#tfplot(WE_M.data <- simulate(WE_M,sampleT=150,start=1900))
WE_M.data <- simulate(WE_M,sampleT=150,noise=matrix(0,150,3),start=1900)
WE_M.f <- forecast(m <- l(WE_M,WE_M.data),horizon=150)
tfplot(WE_M.f)
AIC(m)
WE_Mx <- SS(F=f,H=h,Q=eye(4,3),R=eye(3),z0=c( 0.088538918, 0.009647611, 0.006815983, 1.0000000000),
output.names=c("WE1","WE2","WE3"))
shockDecomposition(WE_Mx)
# To explore Negative Shocks, Uncomment the next line for a -1 sd shock
#shockDecomposition(US_Mx,shock=rep(-1,10))
# To construct probable Counterfactuals, set coefficients between LCI and UCI
#
# LCI Parameter UCI P>=T[1] P< T[1] Std. Dev.
# [1,] 1.013789 1.019120 1.02495 0.43 0.57 0.004927
# [2,] 0.018544 0.021975 0.02583 0.44 0.56 0.003172
# [3,] 0.005900 0.008571 0.01164 0.42 0.58 0.002324
# [4,] -0.030152 -0.008500 0.01056 0.37 0.63 0.016115
# [5,] 1.008405 1.019100 1.03121 0.29 0.71 0.009321
# [6,] 0.021536 0.028376 0.03638 0.36 0.64 0.005925
# [7,] -0.067363 -0.005688 0.05383 0.40 0.60 0.042526
# [8,] -0.068165 -0.039619 -0.01279 0.32 0.68 0.023003
# [9,] 1.010786 1.026267 1.04255 0.19 0.81 0.012924
#[10,] 0.082253 0.088539 0.09488 0.65 0.35 0.005197
#[11,] 0.002130 0.009648 0.01723 0.56 0.44 0.006005
#[12,] 0.002551 0.006816 0.01114 0.52 0.48 0.003643
#