# Cut-and-Paste Code Below into Window Above and Run
#
#
# LA20 TECHP Model
#
merge.forecast <- function (fx,n=1) {
#
# Merges a forecast with the outputdata
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) (L-CO2-Q) (Q-CO2)
# CO2 ENERGY GDP L
#[1,] 0.500 0.5023 0.501 0.497
#[2,] -0.478 -0.1153 -0.239 0.837
#[3,] -0.629 0.0028 0.765 -0.140
#
# Fraction of Variance
#[1] 0.985 0.994 0.998 1.000
#
f <- matrix( c( 0.982054832, 0.2697719, 0.5844705, 0.142124856,
-0.009729417, 0.8757318, -0.3389483, 0.002128448,
-0.008366848, 0.1630589, 0.7409413, -0.007691149,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
LA_TECHP <- SS(F=f,H=h,K=k,z0=c( 0.142124856, 0.002128448, -0.007691149, 1.0000000000),
output.names=c("TECHP1","TECHP2","TECHP3"))
print(LA_TECHP)
is.SS(LA_TECHP)
stability(LA_TECHP)
# tfplot(simulate(LA_TECHP,sampleT=100))
LA_TECHP.data <- simulate(LA_TECHP,sampleT=100,noise=matrix(0,100,3))
LA_TECHP.f <- forecast(l(LA_TECHP,LA_TECHP.data),horizon=100)
LA_TECHP.fx <- merge.forecast(LA_TECHP.f)
tfplot(LA_TECHP.f)
AIC(l(LA_TECHP,LA_TECHP.data))
#
#
#
# LAC_TECHP Input
#
# Measurement Matrix (Growth) (LU-EG-CO2) (N+L-CO2-Q)
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD
#[1,] 0.412 0.412 0.411
#[2,] -0.190 -0.239 -0.272
#[3,] -0.532 -0.169 -0.252
# SL.TLF.TOTL.IN SP.POP.TOTL SL.UEM.TOTL.ZS
#[1,] 0.413 0.41317 0.388
#[2,] -0.144 -0.00377 0.901
#[3,] 0.497 0.59551 -0.152
#
# Fraction of Variance
#[1] 0.972 0.997 0.999 1.000 1.000 1.000
#
f <- matrix( c( 0.997934675, -0.04333051, 0.5178460, 0.16294074,
-0.021285477, 0.92797742, -0.1762071, -0.01029681,
-0.002839782, 0.06006718, 0.6009844, -0.00569632,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
g <- matrix( c( 0.023604896, 0.03881311, 0.05509400,
0.004775344, -0.04757128, 0.10122475,
-0.015304583, -0.03810903, -0.04934033,
0.000000000, 0.00000000, 0.00000000
),byrow=TRUE,nrow=4,ncol=3)
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
LAC_TECHP <- SS(F=f,H=h,K=k,G=g,z0=c( 0.2505234, -0.1123855, -0.10424173, 1.0000000000),
output.names=c("LAC1","LAC2","LAC3"))
print(LAC_TECHP)
is.SS(LAC_TECHP)
stability(LAC_TECHP)
# tfplot(simulate(LAC_TECHP,sampleT=100))
LAC_TECHP.data <- simulate(LAC_TECHP,sampleT=100,noise=matrix(0,100,3),input=LA_TECHP.fx)
LAC_TECHP.f <- forecast(l(LAC_TECHP,LAC_TECHP.data),conditioning.inputs=LA_TECHP.fx)
tfplot(LAC_TECHP.f)
AIC(l(LAC_TECHP,LAC_TECHP.data))