require(dse)
require(matlab)
#
# WL20 BAU Model
#
# Measurement Matrix
# N OIL QA GWP P.Wheat. P.Oil. TEMP CO2
#[1,] 0.2845 0.271 0.2821 0.2824 0.236 0.243 0.251 0.2837
#[2,] -0.0161 0.241 0.0985 -0.1413 0.411 0.066 -0.235 -0.0983
#[3,] -0.1112 -0.241 -0.0883 0.0213 0.461 0.712 0.190 -0.0201
# Carbon TotalFootprint Earths WorldGlobal LivingPlanet URBAN
#[1,] 0.2833 0.275 0.279 0.2819 -0.1839 0.2840
#[2,] 0.0925 0.182 0.148 -0.0926 0.7705 -0.0868
#[3,] -0.0955 -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
#[12] 1.000 1.000 1.000
#
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]}
f <- matrix( c( 1.01169571, -0.02519461, -0.09358484, 0.210941578,
-0.01360718, 0.96330129, -0.05250691, -0.003862528,
0.02303607, -0.03631204, 0.93554760 , 0.018115378,
0.000000000, 0.00000000, 0.0000000, 1.00000000
),byrow=TRUE,nrow=4,ncol=4)
h <- eye(3,4)
k <- f[1:4,1:3,drop=FALSE]
WL20 <- SS(F=f,H=h,K=k,z0=c( 0.210941578, -0.003862528, 0.018115378,
1.0000000),
output.names=c("W1","W2","W3"))
stability(WL20)
shockDecomposition(toSSChol(WL20))
WL20.data <- simulate(WL20,sampleT=50,start=1950)
m <- l(WL20,WL20.data)
# tfplot(m)
AIC(m)
WL20.f <- forecast(m,horizon=50)
WL20.fx <- merge.forecast(WL20.f)
tfplot(WL20.f)
#
# USL20 Capitalism W Input
#
# Output Measurement Model (Growth), (GINI-K), (GINI-I)
# Measurement Matrix
# K.US. Q.I. SI.POV.GINI
#[1,] 0.570 0.585 0.576
#[2,] -0.778 0.159 0.608
#[3,] 0.264 -0.795 0.546
#
# Fraction of Variance
#[1] 0.957 0.992 1.000
f <- matrix( c( 0.7490851, 0.1159106, -0.027488252,
-0.1477020, 0.8557087, -0.005713771,
0.000000000, 0.0000000 ,1.0000000
),nrow=3,ncol=3, byrow=TRUE)
g <- matrix( c( -0.009518509, -0.02905522, 0.051830902,
-0.006051251, -0.01688412, 0.004471607,
0.000000000, 0.0000000 ,1.0000000
),nrow=3,ncol=3, byrow=TRUE)
h <- eye(2,3)
k <- (f[,1:2,drop=FALSE])
US_Capital <- SS(F=f,H=h,G=g,K=k,z0=c( 0.07527316, 0.04027590, 1.0000000),
output.names=c("(GINI-K)", "(GINI-I)"))
print(US_Capital)
is.SS(US_Capital)
stability(US_Capital)
US_Capital.data <- simulate(US_Capital,sampleT=50,noise=matrix(0,50,2),
start=1950,input=WL20.fx)
seriesNames(outputData(US_Capital.data)) <- c("(GINI-K)", "(GINI-I)")
tfplot(US_Capital.data)
shockDecomposition(toSSChol(US_Capital))
#
# BAU
#
f <- matrix( c( 0.93851537, 1.893266e-05, -0.003033047,
-0.09880714, 8.085086e-01, -0.005758227,
0.000000000, 0.0000000 ,1.0000000
),nrow=3,ncol=3, byrow=TRUE)
US_Capital_BAU <- SS(F=f,H=h,K=k,z0=c( -0.003033047, -0.005758227, 1.0000000),
output.names=c("(GINI-K)", "(GINI-I)"))
US_Capital_BAU.data <- simulate(US_Capital_BAU,sampleT=50,noise=matrix(0,50,2),
start=1950,horizon=50)
seriesNames(outputData(US_Capital_BAU.data)) <- c("(GINI-K)", "(GINI-I)")
tfplot(US_Capital_BAU.data)
shockDecomposition(toSSChol(US_Capital_BAU))