# Cut-and-paste code below into window above and Run
#
# Latin America (LA) Model (1950-2000)
#
# Notice: Malthusian Exports and Export Prices
# Measurement Matrix # (Growth), (X-Q-N), (XREAL-X)
#
# Q N XREAL X
#[1,] 0.502 0.499 0.502 0.498
#[2,] -0.476 -0.522 0.468 0.531
#[3,] -0.157 0.105 0.718 -0.670
#
# Fraction of Variance
#[1] 0.936 0.999 1.000 1.000
#
#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.057014434, 0.03272800, -0.2267867, 0.155122312,
0.046045971, 1.05667708, -0.2990176, 0.017729672,
0.001904368, 0.02642842, 0.9723622, 0.005552142,
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.015363848; f[2,2] <- 1.01503979; f[3,3] <- 0.9340473
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
LA_LM <- SS(F=f,H=h,K=k,z0=c(0.155122312, 0.017729672, 0.005552142, 1.0000000000),
output.names=c("LA1","LA2","LA3"))
print(LA_LM)
is.SS(LA_LM)
stability(LA_LM)
LA_LM.data <- simulate(LA_LM,sampleT=100,start=1950)
#LA_LM.data <- simulate(LA_LM,sampleT=100,noise=matrix(0,100,3),start=1950)
LA_LM.f <- forecast(l(LA_LM,LA_LM.data),horizon=150)
LA_LM.fx <- merge.forecast(LA_LM.f)
tfplot(LA_LM.f)
AIC(m <- l(LA_LM,LA_LM.data))
LA_LMx <- SS(F=f,H=h,Q=eye(4,3),R=eye(3,3),z0=c(0.31840994, 0.04194678, 0.0117148, 1.0000000000),
output.names=c("LA1","LA2","LA3"))
shockDecomposition(LA_LMx)
#
# LCI Parameter UCI P>=T[1] P< T[1] Std. Dev. Bias Bias-z
#[1,] 1.026223 1.057014 1.091091 0.36 0.64 0.039091 -0.001037 -0.02654
# [2,] 0.030280 0.046046 0.065626 0.35 0.65 0.021713 1.008919 46.46544
# [3,] -0.001021 0.001904 0.005069 0.42 0.58 0.003167 1.054893 333.08262
# [4,] -0.066662 0.032728 0.140321 0.31 0.69 0.104703 1.038959 9.92294
# [5,] 1.003640 1.056677 1.109185 0.27 0.73 0.059412 0.010074 0.16956
# [6,] 0.019700 0.026428 0.033571 0.38 0.62 0.008001 1.030475 128.79678
# [7,] -0.620309 -0.226787 0.106794 0.33 0.67 0.324671 1.410066 4.34306
#[8,] -0.465998 -0.299018 -0.140359 0.26 0.74 0.149310 1.428356 9.56635
# [9,] 0.937548 0.972362 1.006288 0.19 0.81 0.029713 0.107745 3.62624
#[10,] 0.127593 0.155122 0.182920 0.51 0.49 0.034890 0.892394 25.57720
#[11,] -0.002575 0.017730 0.041207 0.49 0.51 0.023217 1.035400 44.59724
#[12,] 0.002470 0.005552 0.008123 0.53 0.47 0.003055 1.050827 343.98929
#