# Cut-and-Paste Coe below into window above and Run
#
# PT_M Model (1900-2000)
#
# Measurement Matrix (Growth), (X-N), (N-Q)
# Q N U X
#[1,] 0.520 0.488 0.524 0.465
#[2,] 0.267 -0.581 -0.338 0.691
#[3,] -0.655 0.476 -0.260 0.527
#
# Fraction of Variance
#[1] 0.854 0.977 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.021933178, 0.02115352, -0.01791158, 0.072947411,
0.027151093, 1.00805861, -0.04841158, 0.003853785,
0.006984669, 0.03614813, 1.01325902, 0.009616332,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize growth, uncomment the next line
# f[1,1] <- 1.0 ; f[2,2] <- f[3,3] <- 0.98
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
PT_M <- SS(F=f,H=h,K=k,z0=c( 0.072947411, 0.003853785, 0.009616332, 1.0000000000),
output.names=c("PT1","PT2","PT3"))
print(PT_M)
is.SS(PT_M)
stability(PT_M)
#tfplot(PT_M.data <- simulate(PT_M,sampleT=150,start=1900))
PT_M.data <- simulate(PT_M,sampleT=150,noise=matrix(0,150,3),start=1900)
PT_M.f <- forecast(m <- l(PT_M,PT_M.data),horizon=150)
tfplot(PT_M.f)
AIC(m)
PT_Mx <- SS(F=f,H=h,Q=eye(4,3),R=eye(3),z0=c( 0.072947411, 0.003853785, 0.009616332, 1.0000000000),
output.names=c("PT1","PT2","PT3"))
shockDecomposition(PT_Mx)
# To explore Negative Shocks, Uncomment the next line for a -1 sd shock
#shockDecomposition(PT_Mx,shock=rep(-1,10))
# To create probable counterfactuals, set coefficients between LCI and UCI
#
# LCI Parameter UCI P>=T[1] P< T[1] Std. Dev.
# [1,] 1.014782 1.021933 1.03007 0.41 0.59 0.007496
# [2,] 0.023317 0.027151 0.03141 0.41 0.59 0.003856
# [3,] 0.003701 0.006985 0.01054 0.44 0.56 0.003378
# [4,] 0.004368 0.021154 0.03851 0.39 0.61 0.015766
# [5,] 0.998894 1.008059 1.01831 0.29 0.71 0.008554
# [6,] 0.029628 0.036148 0.04283 0.44 0.56 0.006152
# [7,] -0.055728 -0.017912 0.01578 0.32 0.68 0.029014
# [8,] -0.073043 -0.048412 -0.02696 0.34 0.66 0.018967
# [9,] 1.000552 1.013259 1.02696 0.21 0.79 0.012042
#[10,] 0.067583 0.072947 0.07910 0.50 0.50 0.005397
#[11,] -0.003640 0.003854 0.01061 0.47 0.53 0.005755
#[12,] 0.005971 0.009616 0.01343 0.49 0.51 0.003347
#