#
# Paste Code Below into Window above and Run
#
# W_TEHCE Model
#
require(dse)
require(matlab)
#
# Measurement Matrix # (L/N+GDP/L -CO2/EG) (EG/GDP - GDP/L - CO2-EG) (Growth)
# CO2/EG ENERGY/GDP GDP/L L/N
#[1,] -0.557 0.119 0.554 0.607
#[2,] -0.333 0.851 -0.390 -0.117
#[3,] 0.747 0.409 0.100 0.514
#
# Fraction of Variance
#[1] 0.646 0.973 0.997 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]}
f <- matrix( c(0.87076812, -0.06501580, 0.10773054, 0.12675405,
-0.12038820, 0.93048034, 0.06171777, 0.02963129,
0.05959062, 0.06260574, 0.74239631, -0.01976526,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To create unstable, exponential Tech change, uncomment next line
# f[1,1] <- 1.0
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
W_TECHE <- SS(F=f,H=h,K=k,z0=c( 0.111676894, -0.016321163, -0.003205371, 1.0000000000),
output.names=c("W_TECHE1","W_TECHE2","W_TECHE3"))
print(W_TECHE)
is.SS(W_TECHE)
stability(m0 <- SS(F=f[1:3,1:3,drop=FALSE],H=eye(3),Q=eye(3),R=eye(3)))
# tfplot(simulate(W_TECHE,sampleT=58))
W_TECHE.data <- simulate(W_TECHE,sampleT=58,noise=matrix(0,58,3),start=1950)
m <- l(W_TECHE,W_TECHE.data)
W_TECHE.f <- forecast(m,horizon=150)
tfplot(W_TECHE.f)
W_TECHE.fx <- merge.forecast(W_TECHE.f)
AIC(l(W_TECHE,W_TECHE.data))
#
# Bootstrap Coefficients
# LCI Parameter UCI P>=T[1] P< T[1] Std. Dev. Bias Bias-z
# [1,] 0.822171 0.87077 0.914158 0.69 0.31 0.04274 -0.01238 -0.2896
# [2,] -0.159735 -0.12039 -0.084256 0.65 0.35 0.03455 0.98206 28.4220
# [3,] 0.038121 0.05959 0.085637 0.21 0.79 0.01956 0.82474 42.1550
# [4,] -0.108459 -0.06502 -0.024861 0.69 0.31 0.03522 0.92554 26.2806
# [5,] 0.890513 0.93048 0.967311 0.73 0.27 0.03093 -0.07239 -2.3410
# [6,] 0.042261 0.06261 0.084968 0.23 0.77 0.01716 0.81851 47.7048
# [7,] -0.093552 0.10773 0.303777 0.31 0.69 0.15335 0.83708 5.4585
# [8,] -0.115574 0.06172 0.211542 0.31 0.69 0.12697 0.87260 6.8724
# [9,] 0.649745 0.74240 0.825684 0.78 0.22 0.07425 0.08702 1.1720
#[10,] 0.102877 0.12675 0.151127 0.36 0.64 0.02187 0.74816 34.2016
#[11,] 0.000277 0.02963 0.057501 0.27 0.73 0.02205 0.85186 38.6333
#[12,] -0.034133 -0.01977 -0.008563 0.76 0.24 0.01023 0.88510 86.5539
#
#
#
# W_TECH Model (Growth-LP) (LP+P.Wheat.+OIL-TEMP) (P.OIL-P.Wheat.-EF-OIL)
#
#Measurement Matrix
# N OIL QA GWP P.Wheat. P.Oil. TEMP CO2 Carbon
#[1,] 0.2845 0.271 0.2821 0.2824 0.236 0.243 0.251 0.2837 0.2833
#[2,] -0.0161 0.241 0.0985 -0.1413 0.411 0.066 -0.235 -0.0983 0.0925
#[3,] -0.1112 -0.241 -0.0883 0.0213 0.461 0.712 0.190 -0.0201 -0.0955
# TotalFootprint Earths WorldGlobal LivingPlanet URBAN
#[1,] 0.275 0.279 0.2819 -0.1839 0.2840
#[2,] 0.182 0.148 -0.0926 0.7705 -0.0868
#[3,] -0.293 -0.231 -0.0943 -0.0576 -0.0707
# Fraction of Variance
#[1] 0.874 0.941 0.973 0.986 0.995 0.998 0.999 0.999 1.000 1.000 1.000 1.000
#[13] 1.000 1.000
#
f <- matrix( c(1.0482018, -0.04201115, -0.1120644, 0.217356147,
0.3977397, 0.81271154, -0.1153512, -0.004306261,
0.3869382, -0.10210613, 0.8048383, 0.022955406,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
g <- matrix(c(-0.08812727, 0.04282365, 0.13360147,
-0.73474092, 0.79095408, 0.06661441,
-0.69361037, 0.62451379, -0.03931118,
0.00000000, 0.00000000, 0.00000000
),byrow=TRUE,nrow=4,ncol=3)
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
W_TECH <- SS(F=f,H=h,K=k,G=g,z0=c( 0.1952160, -0.1450108, -0.1122894, 1.0000000000),
output.names=c("W_TECH1","W_TECH2","W_TECH3"))
print(W_TECH)
is.SS(W_TECH)
stability(m0 <- SS(F=f[1:3,1:3,drop=FALSE],H=eye(3),Q=eye(3),R=eye(3)))
W_TECH.data <- simulate(W_TECH,input=W_TECHE.fx)
tfplot(outputData(W_TECH.data))