#
# ES4_L16 Model (1450-1640)
#
#
# Measurement Matrix (Growth-X), (Q+U+X-N), (N+X-Q)
# Q N U X
#[1,] 0.498 0.503 0.5025 -0.4966
#[2,] 0.600 -0.304 0.3523 0.6507
#[3,] -0.193 0.796 -0.0414 0.5717
#[4,] -0.596 -0.143 0.7885 0.0557
#
# Fraction of Variance
#[1] 0.981 1.000 1.000 1.000
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
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)
}
require(dse)
require(matlab)
f <- matrix( c(0.9938678237, -0.028134973, -0.08590694, -0.1776972485, 0.0325318318,
0.0048298346, 1.017023506, 0.05963405, 0.1415772339, 0.0024047873,
0.0001853822, -0.004889711, 0.99131942, -0.0001249757, -0.0006316957,
-0.0001477953, -0.001766980, 0.01986975, 1.0709897477, -0.0001463765,
0.00000000, 0.0000000, 0.0000000, 0, 1.0000000000
),byrow=TRUE,nrow=5,ncol=5)
h <- eye(4,5)
k <- (f[,1:4,drop=FALSE])
ES4_L16 <- SS(F=f,H=h,K=k,z0=c( 0.0325318318, 0.0024047873, -0.0006316957, -0.0001463765 , 1.0000000000),
output.names=c("ES1","ES2","ES3","ES4"))
#ES4_L16.data <- simulate(ES4_L16,sampleT=150,start=1450)
ES4_L16.data <- simulate(ES4_L16,sampleT=150,start=1450,noise=matrix(0,150,4))
ES4_L16.f <- forecast(l(ES4_L16,ES4_L16.data),horizon=150)
ES4_L16.fx <- merge.forecast(ES4_L16.f)
#
# LA_L16 Model ES Input (1450-1640)
#
#
# Measurement Matrix # (Growth), (Q-N)
# Q N
#[1,] 0.707 0.707
#[2,] 0.707 -0.707
#
# Fraction of Variance
#
f <- matrix( c(0.25251801, -0.030317232, -0.0055730767,
-0.03722076 , 0.004468712, 0.0008214627,
0.00000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=3,ncol=3)
g <- matrix(c(0.52355661, 0.4457459, -2.1643522, -1.229322,
-0.01508643, 0.7314628, 0.4146945, -1.760046,
0.00000000, 0.0000000, 0.0000000, 0.000000
),byrow=TRUE,nrow=3,ncol=4)
h <- eye(2,3)
k <- (f[,1:2,drop=FALSE])
LA_L16 <- SS(F=f,H=h,G=g,K=k,z0=c( 1.711367, -0.145897, 1.0000000000),
output.names=c("LA1","LA2"))
print(LA_L16)
is.SS(LA_L16)
stability(LA_L16)
# tfplot(simulate(LA_L16,sampleT=100))
# LA_L16.data <- simulate(LA_L16,sampleT=100)
LA_L16.data <- simulate(LA_L16,sampleT=100,noise=matrix(0,100,2),start=1450,input=ES4_L16.fx)
LA_L16.f <- forecast(l(LA_L16,LA_L16.data),horizon=100,conditioning.inputs=ES4_L16.fx)
tfplot(LA_L16.f)
AIC(m <- l(LA_L16,LA_L16.data))
LA_L16x <- SS(F=f,H=h,G=g,R=eye(2),Q=eye(3,2),z0=c( 1.711367, -0.145897, 1.0000000000),
output.names=c("LA1","LA2"))
shockDecomposition(LA_L16x)