# Cut-and-Paste Code below into Window Above and Run
#
# WMA (Middle Ages) Model
#
# Measurement Matrix (Growth-T), (Growth), (Q-N)
# Q N T
#[1,] 0.666 0.689 -0.286
#[2,] 0.290 0.115 0.950
#[3,] 0.688 -0.716 -0.123
#
# Fraction of Variance
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
f <- matrix( c(1.009209e+00, -5.212984e-03, -2.7763749, 6.644212e-03,
2.775262e-03, 9.984308e-01, -0.8367732, -1.637815e-03,
6.840086e-06, 9.757525e-06, 0.9970411, 5.546619e-06,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
# To create Random Walk, Uncomment next line
#f[1,1] <- f[2,2] <- f[3,3] <- 1
# To stabilize, Uncomment next line
#f[1,1] <- f[2,2] <- f[3,3] <- .9
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
WMA <- SS(F=f,H=h,K=k,z0=c( 6.644212e-03, -1.637815e-03, 5.546619e-06, 1.0000000000),output.names=c("W1","W2","W3"))
print(WMA)
is.SS(WMA)
m <- SS(F=f[1:3,1:3,drop=FALSE],Q=eye(3),R=eye(3),H=eye(3))
m
stability(m)
WMA.data <- simulate(WMA,sampleT=100,start=500)
# WMA.data <- simulate(WMA,sampleT=20,noise=matrix(0,20,3))
WMA.f <- forecast(m <- l(WMA,WMA.data),horizon=50)
tfplot(WMA.f)
AIC(m)
WMAx <- SS(F=f,H=h,Q=eye(4,3),R=eye(3,3),z0=c( 6.644212e-03, -1.637815e-03, 5.546619e-06, 1.0000000000),
output.names=c("W1","W2","W3"))
shockDecomposition(WMAx)