#
# AXJ_LM Model (cut-and-paste code into window above and Run (Cmd-Enter)
#
#
# Measurement Matrix (Growth), (N-XREAL), (Q-XREAL)
# Q N XREAL
#[1,] 0.5809 0.5736 0.5775
#[2,] -0.2243 0.7949 -0.5638
#[3,] 0.7825 -0.1979 -0.5904
#
# Fraction of Variance
#[1] 0.9857 1.0000 1.0000
#
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)
f <- matrix( c(1.032483086, 0.0893329688, 7.3532892, 1.146422e-01,
-0.015620695, 0.9745223725, -6.5969415, 1.761040e-03,
0.000010184, 0.0007955634, 0.8679133, -7.008574e-05,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# Stabilize Asian Growth
# (Uncommment next command)
#
# f[1,1] <- 1
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
AXJLM <- SS(F=f,H=h,K=k,z0=c( 1.146422e-01, 1.761040e-03, -7.008574e-05, 1.0000000000),
output.names=c("AXJ1","AXJ1","AXJ1"))
print(AXJLM)
is.SS(AXJLM)
stability(AXJLM)
# tfplot(simulate(AXJLM,sampleT=100))
AXJLM.data <- simulate(AXJLM,sampleT=100,noise=matrix(0,100,3))
AXJLM.f <- forecast(l(AXJLM,AXJLM.data),horizon=100)
AXJM.fx <- merge.forecast(AXJLM.f)
tfplot(AXJLM.f)
AIC(l(AXJLM,AXJLM.data))
q <- matrix( c( 0.3075393229, 4.394617e-04, 3.442278e-05,
0.0576136724, 2.775657e-03, -3.088211e-05,
-0.0002702703, 2.256986e-05, 4.062942e-06,
0.00000000, 0.0000000, 0.0000000
),byrow=TRUE,nrow=4,ncol=3)
r <- matrix( c( 0.2951994354, 0.000000e+00, 0.000000e+00,
0.0613396050, 3.005610e-03, 0.000000e+00,
-0.0003710925, 2.324968e-05, 4.681277e-06
),byrow=TRUE,nrow=3,ncol=3)
AXJLM2 <- SS(F=f,H=h,Q=q,R=r,z0=c( 1.146422e-01, 1.761040e-03, -7.008574e-05, 1.0000000000),
output.names=c("AXJ1","AXJ1","AXJ1"))
shockDecomposition(AXJLM2)
#
# WL20 India
#
#
# India IN_LM Model
#
require(dse)
require(matlab)
#
# Measurement Matrix (Growth) (N-Q)
# Q N
#[1,] 0.7071 0.7071
#[2,] -0.7071 0.7071
#
# Fraction of Variance
#[1] 0.9919 1.0000
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
f <- matrix( c( 2.416284e-13, 4.538441e-13, 2.227908e-14,
-4.026590e-14, -9.208321e-14, -3.864347e-15,
0.0000000, 0.0000000, 1.0000000
),byrow=TRUE,nrow=3,ncol=3)
g <- matrix(c(0.81867254, 0.2053109, 3.308165,
-0.00223055, 0.6147680, 1.405612,
0.00000000, 0.0000000, 0.000000
),byrow=TRUE,nrow=3,ncol=3)
h <- eye(2,3)
k <- f[1:3,1:2,drop=FALSE]
INLM <- SS(F=f,H=h,K=k,z0=c( -1.6951995, -0.2577112, 1.0000000),
output.names=c("Growth","N-Q"))
stability(INLM)
#tfplot(simulate(INLM,sampleT=100,noise=matrix(0,100,2),start=1,input=AXJM.fx))
INLM.data <- simulate(INLM,sampleT=100,start=1,input=AXJM.fx)
m <- l(INLM,INLM.data)
#tfplot(m)
INLM.f <- forecast(m,horizon=100,input=AXJM.fx)
tfplot(INLM.f)
AIC(m)