#
# Cut-and-Paste Code below into Window above and Run
#
# help(dse)
# help(SS)
#
# MX_CA_US BAU Growth
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
f <- matrix( c( 0.84622592, 0.10015399, 0.017055955, 0.1341106,
0.15941197 ,0.85507471, -0.008681849, 0.2023554,
-0.08741621, 0.09587767, 1.020424021, 0.3066352,
0.000000000, 0.0000000 ,0.00000, 1.0000000
),nrow=4,ncol=4, byrow=TRUE)
# To stabilize, Set US to a Random Walk
# f[3,3] <- 1
# Or, equalize Growth Rates
# f[3,3] <- 0.85
# Or, also set MX to a Random Walk
# f[1,1] <- 1
# Set all to Random Walks with feedback
# f[1,1] <- f[2,2] <- f[3,3] <- 1
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
MX_CA_US <- SS(F=f,H=h,K=k,z0=c( 0.1341106, 0.2023554, 0.3066352, 1.0000000),
output.names=c("MX1", "CA1", "US1"))
print(MX_CA_US)
#is.SS(MX_CA_US)
stability(SS(F=f[1:3,1:3,drop=FALSE],H=eye(3),Q=eye(3),R=eye(3)) )
MX_CA_US.data <- simulate(MX_CA_US,sampleT=150,noise=matrix(0,150,3),start=1960)
tfplot(MX_CA_US.data)
MX_CA_US.f <- forecast(l(MX_CA_US,MX_CA_US.data),horizon=150,start=1960)
tfplot(MX_CA_US.f)
AIC(l(MX_CA_US,MX_CA_US.data))
shockDecomposition(toSSChol(MX_CA_US),shock=-1)