# Cut-and-paste code below into window above and Run
#
# China (CN) Model (1950-2000)
#
# Measurement Matrix (Growth), (X-HOURS), (HOURS-U)
#
# Measurement Matrix
# Q N U HOURS XREAL X L
#[1,] 0.389 0.388 0.388 0.354 0.387 0.345 0.3906
#[2,] -0.145 -0.199 0.180 -0.618 0.210 0.687 -0.0917
#[3,] -0.212 -0.275 -0.547 0.566 0.224 0.446 -0.1031
#
# Fraction of Variance
#[1] 0.933 1.000 1.000 1.000 1.000 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(0.986091451, -0.02842443, -0.4585358, 0.165226628,
0.034833406, 1.02993562, 0.5527579, 0.014032953,
0.001291216, -0.01073976, 0.8885394, -0.003541658,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize model, uncomment next line
# f[1,1] <- 0.976230536; f[2,2] <- 1.01963627; f[3,3] <- 0.8796540
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
CN_LM <- SS(F=f,H=h,K=k,z0=c(0.165226628, 0.014032953, -0.003541658, 1.0000000000),
output.names=c("CN1","CN2","CN3"))
print(CN_LM)
is.SS(CN_LM)
stability(CN_LM)
CN_LM.data <- simulate(CN_LM,sampleT=100,start=1950)
#CN_LM.data <- simulate(CN_LM,sampleT=100,noise=matrix(0,100,3),start=1950)
CN_LM.f <- forecast(l(CN_LM,CN_LM.data),horizon=150)
CN_LM.fx <- merge.forecast(CN_LM.f)
tfplot(CN_LM.f)
AIC(m <- l(CN_LM,CN_LM.data))
CN_LMx <- SS(F=f,H=h,Q=eye(4,3),R=eye(3,3),z0=c(0.329380291, 0.032283718, -0.006625928, 1.0000000000),
output.names=c("CN1","CN2","CN3"))
shockDecomposition(CN_LMx)
#
# LCI Parameter UCI P>=T[1] P< T[1] Std. Dev. Bias Bias-z
# [1,] 0.971425 0.986091 0.998362 0.43 0.57 0.0114745 0.001948 0.1698
# [2,] 0.029592 0.034833 0.042743 0.48 0.52 0.0056948 0.950907 166.9776
# [3,] 0.000336 0.001291 0.002214 0.43 0.57 0.0009726 0.984814 1012.6070
# [4,] -0.079432 -0.028424 0.022407 0.46 0.54 0.0393966 1.018616 25.8554
# [5,] 1.004458 1.029936 1.061731 0.29 0.71 0.0234094 -0.033634 -1.4368
# [6,] -0.013603 -0.010740 -0.008836 0.68 0.32 0.0021795 0.996616 457.2645
# [7,] -1.434932 -0.458536 0.395450 0.58 0.42 0.7782848 1.324269 1.7015
# [8,] 0.061739 0.552758 1.013950 0.71 0.29 0.3896567 0.346946 0.8904
# [9,] 0.800759 0.888539 0.958785 0.47 0.53 0.0657403 0.112482 1.7110
#[10,] 0.153784 0.165227 0.175926 0.63 0.37 0.0110575 0.816766 73.8650
#[11,] -0.005895 0.014033 0.033933 0.48 0.52 0.0154570 0.970760 62.8039
#[12,] -0.005243 -0.003542 -0.001926 0.57 0.43 0.0014669 0.989604 674.6288
#