# Cut-and-paste code below into window above and Run
#
# Mexico (MX) Model (1950-2000)
#
#
# Measurement Matrix # overall , (HOURS-N) , (Q-N)
#
# Q N HOURS
#[1,] 0.579 0.577 0.576
#[2,] -0.147 -0.621 0.770
#[3,] 0.802 -0.530 -0.275
#
#Fraction of Variance
#[1] 0.995 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.0194883298, -0.07800042, 0.1915458, 0.1165387477,
0.0093824710, 0.99995422, 0.6621760, 0.0005986337,
0.0001282613, -0.0098748, 0.8806978, -0.0005425660,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize model, uncomment next three lines
# f[1,1] <- 1.0092934465; f[2,2] <- 0.98995468; f[3,3] <- 0.8718908
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
MX_LM <- SS(F=f,H=h,K=k,z0=c(0.1165387477, 0.0005986337, -0.0005425660, 1.0000000000),
output.names=c("MX1","MX2","MX3"))
print(MX_LM)
is.SS(MX_LM)
stability(MX_LM)
MX_LM.data <- simulate(MX_LM,sampleT=100,start=1950)
#MX_LM.data <- simulate(MX_LM,sampleT=100,noise=matrix(0,100,3),start=1950)
MX_LM.f <- forecast(l(MX_LM,MX_LM.data),horizon=150)
MX_LM.fx <- merge.forecast(MX_LM.f)
tfplot(MX_LM.f)
AIC(m <- l(MX_LM,MX_LM.data))
MX_LMx <- SS(F=f,H=h,Q=eye(4,3),R=eye(3,3),z0=c(0.235198021, 0.001931387, -0.001011367, 1.0000000000),
output.names=c("MX1","MX2","MX3"))
shockDecomposition(MX_LMx)
#
# LCI Parameter UCI P>=T[1] P< T[1] Std. Dev. Bias Bias-z
# [1,] 1.007e+00 1.0194883 1.0318210 0.34 0.66 0.0096015 0.003166 0.3298
#[2,] 8.122e-03 0.0093825 0.0108959 0.46 0.54 0.0011494 1.010159 878.8437
# [3,] -2.821e-05 0.0001283 0.0003276 0.46 0.54 0.0001435 1.019362 7102.4015
# [4,] -2.687e-01 -0.0780004 0.0885957 0.39 0.61 0.1494211 1.147215 7.6777
# [5,] 9.751e-01 0.9999542 1.0284641 0.28 0.72 0.0195296 0.031682 1.6222
# [6,] -1.241e-02 -0.0098748 -0.0076425 0.63 0.37 0.0021144 1.028830 486.5726
# [7,] -4.203e+00 0.1915458 3.4189597 0.62 0.38 2.7446313 0.320593 0.1168
# [8,] 1.479e-01 0.6621760 1.1945156 0.70 0.30 0.4031704 0.144613 0.3587
# [9,] 7.829e-01 0.8806978 0.9398796 0.48 0.52 0.0612985 0.153272 2.5004
#[10,] 1.081e-01 0.1165387 0.1269978 0.61 0.39 0.0078555 0.899337 114.4850
#[11,] -2.823e-03 0.0005986 0.0038494 0.45 0.55 0.0024863 1.019040 409.8622
#[12,] -8.125e-04 -0.0005426 -0.0003189 0.64 0.36 0.0001791 1.020003 5694.1640
#