# Cut-and-Paste Code below into window above and Run
#
# DE_HMA World Model (High Middle Ages 1150-1300)
#
# Measurement Matrix
# Q N U
#[1,] 0.579 0.576 0.577
#[2,] -0.223 0.793 -0.567
#[3,] 0.784 -0.199 -0.588
#
#Fraction of Variance
#[1] 0.990 0.998 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.0022981931, -0.004419900, -0.001760842, 0.0130358631,
0.0003848243, 0.995212018, 0.041535081, -0.0009940053,
-0.0004372560, -0.009051723, 1.011624811, -0.0008587574,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To Stabilize, Uncomment next two lines
# f[1,1] <- f[3,3] <- 0.99
# f[2,2] <- 0.99
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
DE_HMA <- SS(F=f,H=h,K=k,z0=c( 0.0130358631, -0.0009940053, -0.0008587574, 1.0000000000),
output.names=c("DE1","DE2","DE3"))
print(DE_HMA)
is.SS(DE_HMA)
stability(DE_HMA)
tfplot(DE_HMA.data <- simulate(DE_HMA,sampleT=150,start=1150))
#DE_HMA.data <- simulate(DE_HMA.data <-sampleT=150,noise=matrix(0,150,3))
DE_HMA.f <- forecast(m <- l(DE_HMA,DE_HMA.data),horizon=150,start=1150)
tfplot(DE_HMA.f)
AIC(m)
shockDecomposition(toSSChol(m))
#
# To Run Counterfactuals, set coefficients between LCI and UCI
#
# LCI Parameter UCI P>=T[1] P< T[1] Std. Dev. Bias Bias-z
# [1,] 1.0018572 1.0022982 1.0028232 0.39 0.61 3.682e-04 6.714e-05 0.1824
# [2,] 0.0002673 0.0003848 0.0005235 0.61 0.39 1.072e-04 1.002e+00 9347.5233
# [3,] -0.0005245 -0.0004373 -0.0003568 0.60 0.40 7.080e-05 1.003e+00 14163.4056
# [4,] -0.0096209 -0.0044199 0.0007225 0.51 0.49 3.681e-03 1.007e+00 273.4599
# [5,] 0.9944609 0.9952120 0.9959600 0.30 0.70 5.726e-04 7.361e-03 12.8570
# [6,] -0.0096953 -0.0090517 -0.0084360 0.44 0.56 4.519e-04 1.011e+00 2238.1750
# [7,] -0.0173332 -0.0017608 0.0095303 0.62 0.38 1.046e-02 1.002e+00 95.7468
# [8,] 0.0376142 0.0415351 0.0462534 0.35 0.65 3.267e-03 9.617e-01 294.3519
# [9,] 1.0090351 1.0116248 1.0139216 0.33 0.67 2.091e-03 -8.406e-03 -4.0191
#[10,] 0.0128211 0.0130359 0.0132901 0.48 0.52 1.940e-04 9.892e-01 5099.0522
#[11,] -0.0011605 -0.0009940 -0.0008086 0.50 0.50 1.327e-04 1.003e+00 7560.7799
#[12,] -0.0009675 -0.0008588 -0.0007431 0.57 0.43 8.021e-05 1.003e+00 12505.7807
#