#
# ITL20 Model
#
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)
#
#Measurement Matrix # (Growth) (KOF+HDI-LU-CO2-EF) (LU+KOF-N-CO2-EG)
#
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD SL.TLF.TOTL.IN SP.POP.TOTL
#[1,] 0.339 0.3443 0.3484 0.3405 0.334
#[2,] -0.294 -0.0659 0.1960 0.0237 -0.127
#[3,] -0.227 -0.2070 0.0294 -0.1931 -0.398
# SL.UEM.TOTL.ZS KOF EF HDI
#[1,] 0.302 0.311 0.3345 0.343
#[2,] -0.438 0.705 -0.2886 0.287
#[3,] 0.795 0.208 -0.0757 0.167
#
# Fraction of Variance
#[1] 0.897 0.941 0.973 0.992 0.997 0.999 0.999 1.000 1.000
#
f <- matrix( c(0.968655232, -0.02598538, 0.03516609, 0.179538123,
0.024010353, 0.97990001, 0.04937189, 0.002069449,
0.008391537, -0.09476080, 0.9427935,3 -0.024306816,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
ITL20 <- SS(F=f,H=h,K=k,z0=c( 0.179538123, 0.002069449, -0.024306816, 1.0000000000),
output.names=c("IT1","IT2","IT3"))
print(ITL20)
is.SS(ITL20)
stability(m1<-SS(F=f[1:3,1:3,drop=FALSE],Q=eye(3),R=eye(3),H=eye(3)))
shockDecomposition(m1)
# tfplot(simulate(ITL20,sampleT=100))
ITL20.data <- simulate(ITL20,sampleT=150,noise=matrix(0,150,3),start=1960)
ITL20.f <- forecast(m <- l(ITL20,ITL20.data),horizon=150)
tfplot(ITL20.f)
AIC(m)
# Bootstrap 98% Confidence Intervals on System Matrix
#
# [1,] 0.9509829 0.968655 0.98376 0.44 0.56 0.013122 0.004095
# [2,] 0.0203420 0.024010 0.02901 0.61 0.39 0.003766 0.943208
# [3,] 0.0007377 0.008392 0.01722 0.41 0.59 0.006715 0.961059
# [4,] -0.0753380 -0.025985 0.02028 0.57 0.43 0.053785 0.989819
# [5,] 0.9603155 0.979900 1.00068 0.33 0.67 0.016208 -0.002817
# [6,] -0.1262214 -0.094761 -0.07080 0.28 0.72 0.021919 1.079435
# [7,] -0.0348785 0.035166 0.09374 0.52 0.48 0.053800 0.933050
# [8,] 0.0198501 0.049372 0.07780 0.61 0.39 0.021761 0.912290
# [9,] 0.9113850 0.942794 0.98247 0.28 0.72 0.029367 0.039541
#[10,] 0.1574308 0.179538 0.20413 0.68 0.32 0.020658 0.777594
#[11,] -0.0154832 0.002069 0.01767 0.44 0.56 0.012102 0.967430
#[12,] -0.0396002 -0.024307 -0.01254 0.42 0.58 0.013663 0.996519
#