# Cut-and-Paste Code below into Window Above and Run
#
# WE_MA Model (Western Europe)
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
#
# WE_MA (Middle Ages) Model
#
# Measurement Matrix # overall, (Q-U), (N-U-Q)
# Q N U
#[1,] 0.5423 0.62813 0.5580
#[2,] 0.7390 -0.04061 -0.6724
#[3,] -0.3997 0.77705 -0.4862
#
# Fraction of Variance
#[1] 0.8423 0.9988 1.0000
#
f <- matrix( c(1.006355e+00, -0.0023391221, 0.0009808681, 0.0065666458,
4.047844e-03 , 1.0019114386, -0.0150133488, 0.0008499274,
6.299227e-05, 0.0003741214, 0.9991135179, 0.0001306726,
0.000000e+00, 0.0000000000, 0.0000000000, 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])
WE_MA <- SS(F=f,H=h,K=k,z0=c( 0.0065666458, 0.0008499274, 0.0001306726, 1.0000000000),output.names=c("WE1","WE2","WE3"))
print(WE_MA)
is.SS(WE_MA)
m <- SS(F=f[1:3,1:3,drop=FALSE],Q=eye(3),R=eye(3),H=eye(3))
m
stability(m)
WE_MA.data <- simulate(WE_MA,sampleT=1000,start=500)
# WE_MA.data <- simulate(WE_MA,sampleT=1000,noise=matrix(1000))
WE_MA.f <- forecast(m <- l(WE_MA,WE_MA.data),horizon=50)
tfplot(WE_MA.f)
AIC(m)
shockDecomposition(toSSChol(m))