#
# Cut-and-Paste code below into Window Above and Run
#
# IN_LM_SC India Small Country Model
#
# AXJ Regional Input Input (RE)
#
#
# AXJ Asia minus Japan (1950-2000)
#
#Measurement Matrix (Growth) (HOURS) (X-N)
#
# Q N XREAL
#[1,] 0.581 0.574 0.578
#[2,] -0.224 0.795 -0.564
#[3,] 0.782 -0.198 -0.590
#
# Fraction of Variance
#[1] 0.986 1.000 1.000
#
merge.forecast <- function (fx,n=1) {
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)
#
# To stabilize model, uncomment next line
# f[1,1] <- .98
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
AXJ_LM <- SS(F=f,H=h,K=k,z0=c(1.146422e-01, 1.761040e-03, -7.008574e-05, 1.0000000000),
output.names=c("AXJ1","AXJ2","AXJ3"))
print(AXJ_LM)
is.SS(AXJ_LM)
stability(AXJ_LM)
AXJ_LM.data <- simulate(AXJ_LM,sampleT=100,start=1950)
#AXJ_LM.data <- simulate(AXJ_LM,sampleT=100,noise=matrix(0,100,3),start=1950)
AXJ_LM.f <- forecast(l(AXJ_LM,AXJ_LM.data),horizon=150)
AXJ_LM.fx <- merge.forecast(AXJ_LM.f)
#
# IN_LM_SC Model
#
# Measurement Matrix
# Q N
#[1,] 0.707 0.707
#[2,] 0.707 -0.707
#
# Fraction of Variance
#[1] 1 1
#
merge.forecast <- function (fx,n=1) {
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( -2.605049e-13, 3.270199e-13, -2.461127e-14,
-1.117852e-13 ,1.252353e-13, -1.038220e-14,
0.000000000, 0.00000000, 1.0000000000)
,byrow=TRUE,nrow=3,ncol=3)
# To Random Walk, uncomment next line
# f <- eye(3)
#
g <- matrix( c( 0.81867254, 0.2053109, 3.308165,
0.00223055, -0.6147680, -1.405612,
0.000000000, 0.000000, 0.0000000)
,byrow=TRUE,nrow=3,ncol=3)
h <- eye(2,3)
k <- (f[,1:2,drop=FALSE])
IN_LM <- SS(F=f,H=h,K=k,G=g,z0=c(-1.6951995, 0.2577112, 1.0000000000),
output.names=c("IN1","IN2"))
print(IN_LM)
is.SS(IN_LM)
stability(IN_LM)
tfplot(outputData(IN_LM.data <- simulate(IN_LM,sampleT=250,start=1950,input=AXJ_LM.fx)))
#IN_LM.data <- simulate(IN_LM,sampleT=250,noise=matrix(0,250,2))
m <- l(IN_LM,IN_LM.data)
AIC(m)
shockDecomposition(toSSChol(m))