# Cut-and-Paste code below into window above and Run
#
# WHMA World Model (High Middle Ages 1150-1300)
#
#Measurement Matrix (Growth-T), (Growth), (Q-N)
# Q N T
#[1,] 0.581 0.588 -0.563
#[2,] 0.498 0.290 0.817
#[3,] 0.644 -0.755 -0.124
# Fraction of Variance
#[1] 0.954 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.015361e+00, -1.463589e-02, -7.2070444, 3.835857e-02,
1.058868e-02, 9.899117e-01, -4.9688902, -1.546679e-03,
3.359256e-07, 5.104406e-06, 0.9947277, 8.856679e-07,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To Stabilize Growth
# Uncomment next line
# f[1,1] <- .99
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
WHMA <- SS(F=f,H=h,K=k,z0=c( 3.835857e-02, -1.546679e-03, 8.856679e-07, 1.0000000000),
output.names=c("W1","W2","W3"))
print(WHMA)
is.SS(WHMA)
stability(SS(F=f[1:3,1:3,drop=FALSE],H=eye(3),Q=eye(3),R=eye(3)))
tfplot(WHMA.data <- simulate(WHMA,sampleT=150,start=1150))
#WHMA.data <- simulate(WHMA.data <-sampleT=150,noise=matrix(0,150,3))
WHMA.data <- simulate(m <- l(WHMA,WHMA.data),sampleT=150)
WHMA.f <- forecast(m,horizon=150)
tfplot(WHMA.f)
WHMA.fx <- merge.forecast(WHMA.f)
AIC(m)
shockDecomposition(toSSChol(m))