#
# FR TECH MODELS
#
# Cut-and-Paste Code Below into Window Above and Run
#
#
# FRL20 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 (Q+L+EG-CO2) (CO2+E+Q-L) (L+CO2-EG)
#
# CO2 ENERGY GDP L
#[1,] -0.390 0.502 0.571 0.520
#[2,] 0.763 0.541 0.262 -0.237
#[3,] 0.506 -0.317 -0.100 0.796
#
# Fraction of Variance
#[1] 0.717 0.927 0.998 1.000
#
# Fraction of Variance
#[1] 0.985 0.994 0.998 1.000
#
f <- matrix( c( 1.00131161, 0.04449442, -0.07097867, 0.08711843,
-0.05137184, 0.87266880, -0.01075242, 0.03163489,
0.02075841, -0.05766706, 0.96359190, 0.02414442,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
FR_TECHP <- SS(F=f,H=h,K=k,z0=c( 0.08711843, 0.03163489, 0.02414442, 1.0000000000),
output.names=c("TECHP1","TECHP2","TECHP3"))
print(FR_TECHP)
is.SS(FR_TECHP)
stability(SS(F=f[1:3,1:3,drop=FALSE],H=eye(3),R=eye(3),Q=eye(3)))
# tfplot(simulate(FR_TECHP,sampleT=100))
FR_TECHP.data <- simulate(FR_TECHP,sampleT=100,noise=matrix(0,100,3))
FR_TECHP.f <- forecast(l(FR_TECHP,FR_TECHP.data),horizon=100)
FR_TECHP.fx <- merge.forecast(FR_TECHP.f)
tfplot(FR_TECHP.f)
AIC(l(FR_TECHP,FR_TECHP.data))
#
# FRL20 TECHE Model
#
#
# Measurement Matrix (GDP+L-EG-CO2) (L+CO2-Q-EG) (EG+L+Q)
#
# CO2 ENERGY GDP L
#[1,] -0.5039 -0.505 0.516 0.474
#[2,] 0.5317 -0.307 -0.404 0.678
#[3,] -0.0739 0.805 0.212 0.549
#
# Fraction of Variance
#[1] 0.861 0.963 0.995 1.000
#
f <- matrix( c( 1.0036722797, -0.06557970, 0.13593529, 0.104894812,
0.0371672735, 0.97305553, 0.05352367, 0.005908280,
-0.0001591622, 0.01872759, 0.67418737, 0.007143925,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
FR_TECHE <- SS(F=f,H=h,K=k,z0=c( 0.104894812, 0.005908280, 0.007143925, 1.0000000000),
output.names=c("TECHE1","TECHE2","TECHE3"))
print(FR_TECHE)
is.SS(FR_TECHE)
stability(SS(F=f[1:3,1:3,drop=FALSE],H=eye(3),R=eye(3),Q=eye(3)))
# tfplot(simulate(FR_TECHE,sampleT=100))
FR_TECHE.data <- simulate(FR_TECHE,sampleT=100,noise=matrix(0,100,3))
FR_TECHE.f <- forecast(l(FR_TECHE,FR_TECHE.data),horizon=100)
FR_TECHE.fx <- merge.forecast(FR_TECHE.f)
tfplot(FR_TECHE.f)
AIC(l(FR_TECHE,FR_TECHE.data))