#
# WL20 World Input Model
#
merge.forecast <-
function (fx,n=1) {
#
# Merges a forecast with the output data
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.000000000, 0.00000000, 0.00000000, 0.00000000,
0.210941578, 1.01169571, -0.02519461, -0.09358484,
-0.003862528, -0.01360718, 0.96330129, -0.05250691,
0.018115378, 0.02303607, -0.03631204, 0.93554760
),byrow=TRUE,nrow=4,ncol=4)
h <- matrix( c( 0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
),byrow=TRUE,nrow=3,ncol=4)
k <- matrix(c( 0.00000000, 0.00000000, 0.00000000,
1.01169571, -0.01360718, 0.02303607,
-0.02519461, 0.96330129, -0.03631204,
-0.09358484, -0.05250691, 0.93554760
),byrow=TRUE,nrow=4,ncol=3)
WL20 <- SS(F=f,H=h,K=k,z0=c(1.0000000, -5.3541066, -0.7239263, 0.7703831),
output.names=c("W1","W2","W3"))
print(WL20)
is.SS(WL20)
stability(WL20)
# tfplot(simulate(WL20,sampleT=100))
WL20.data <- simulate(WL20,sampleT=100,noise=matrix(0,100,3),start=1950)
WL20.f <- forecast(l(WL20,WL20.data),horizon=50)
tfplot(WL20.f)
AIC(l(WL20,WL20.data))
WL20.fx <- merge.forecast(WL20.f)
#
# ATC Model
#
require(dse)
require(matlab)
# Measurement Matrix
#Measurement Matrix
# Domestic_Passengers_M International_Passengers_M Total_Passengers_M
#[1,] 0.290 0.235 0.322
#[2,] 0.467 0.617 -0.202
#[3,] 0.157 0.290 -0.016
# Domestic_RPM_B International_RPM_B Total_RPM_B Domestic_ASM_B
#[1,] 0.3353 0.3347 0.3367 0.3266
#[2,] -0.0441 -0.1129 -0.0643 -0.2504
#[3,] -0.0470 0.0672 -0.0140 0.0114
# International_ASM_B Total_ASM_B Domestic_Load_Factor_pct
#[1,] 0.3029 0.3287 -0.282
#[2,] -0.0423 -0.2193 0.191
#[3,] 0.4042 0.0795 0.480
# International_Load_Factor_pct
#[1,] -0.183
#[2,] -0.439
#[3,] 0.696
#
# Fraction of Variance
# [1] 0.791 0.888 0.979 0.992 0.996 0.999 1.000 1.000 1.000 1.000 1.000
#
#
f <- matrix( c( 0.97915821, -0.05438097, 0.13591328,
0.04059738, 0.93918308, 0.08953068,
0.0000000, 0.0000000, 1.0000000
),byrow=TRUE,nrow=3,ncol=3)
h <- eye(2,3)
k <- f[1:3,1:2,drop=FALSE]
g <- matrix(c(0.02331203, 0.05617214, -0.08437219,
-0.03358106,-0.02167083, -0.08767120,
0.00000000, 0.00000000, 0.00000000
),byrow=TRUE,nrow=3,ncol=3)
#
# Eliminate World Input, Uncomment next line
# g <- matrix(0,3,3)
ATC <- SS(F=f,H=h,K=k,G=g,z0=c( -0.07841827, 0.22438193 , 1.0000000),
output.names=c("ATC1","ATC2"))
stability(ATC)
shockDecomposition(toSSChol(ATC))
#tfplot(simulate(ATC,sampleT=50,noise=matrix(0,50,2),start=1950))
ATC.data <- simulate(ATC,sampleT=100,start=1950,noise=matrix(0,100,2),input=WL20.fx)
m <- l(ATC,ATC.data)
tfplot(m)
AIC(m)