# Cut-and-paste code below into window above and Run
#
# World System -- Iran (1950-2000)
#
#
#Measurement Matrix (Growth), (LU+KOF) (KOF-EF-LU-EG)
#
# Measurement Matrix
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD SL.TLF.TOTL.IN SP.POP.TOTL SL.UEM.TOTL.ZS HDI EF KOF
#[1,] 0.3664 0.357 0.36749 0.36983 0.35974 0.0381 0.3639 0.359 0.273
#[2,] -0.1003 -0.190 -0.00213 0.00266 -0.00723 0.9091 0.0550 -0.109 0.335
#[3,] -0.0184 -0.217 0.10426 -0.09812 -0.16570 -0.3878 0.0648 -0.258 0.827
#
#Fraction of Variance
#[1] 0.801 0.924 0.979 0.995 0.998 0.999 1.000 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.01282761, -0.02297798, 0.01177121, 0.174120663,
-0.01833407, 0.93276396, 0.14397290, 0.013356943,
-0.01894606, -0.04263376, 0.93461548, 0.005099341,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize model, uncomment next line
# f[1,1] <- 0.99267234 ; f[2,2] <- 0.91420196; f[3,3] <- 0.91601663
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
IR_LM <- SS(F=f,H=h,K=k,z0=c(0.174120663, 0.013356943, 0.005099341, 1.0000000000),
output.names=c("IR1","IR2","IR3"))
print(IR_LM)
is.SS(IR_LM)
stability(IR_LM)
IR_LM.data <- simulate(IR_LM,sampleT=100,start=1950)
#IR_LM.data <- simulate(IR_LM,sampleT=100,noise=matrix(0,100,3),start=1950)
IR_LM.f <- forecast(l(IR_LM,IR_LM.data),horizon=150)
IR_LM.fx <- merge.forecast(IR_LM.f)
tfplot(IR_LM.f)
#
# World System with Iran Input # (Growth-Living Planet), (Living Planet - TEMP) (P.OIL + P.Wheat - EF - Earths)
#
# 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
f <- matrix( c( 0.7170305, 0.07664195, -0.09079280, 0.6150190,
0.1268621, 0.74566835, 0.08042742, -0.1787823,
-0.1910752, -0.03247569, 0.97341666, 0.3096958,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize model, uncomment next line
# f[3,3] <- .90
#
g <- matrix( c( 0.4093634, -0.04138191, -0.10035658,
-0.2336921, 0.14439256, 0.29190548,
0.2876086, 0.03858389, 0.04058617,
0.000000000, 0.000000, 0.0000000)
,byrow=TRUE,nrow=4,ncol=3)
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
W_IR <- SS(F=f,H=h,K=k,G=g,z0=c(0.7568211, -0.2555046, 0.4115690, 1.0000000000),
output.names=c("W1","W2","W3"),input.names=c("IR1","IR2","IR3"))
print(W_IR)
is.SS(W_IR)
stability(W_IR)
# W_IR.data <- simulate(W_IR,sampleT=250,start=1950,input=IR_LM.fx)
W_IR.data <- simulate(W_IR,sampleT=250,noise=matrix(0,250,3),input=IR_LM.fx)
m <- l(W_IR,W_IR.data)
tfplot(m)
AIC(m)
shockDecomposition(W_IR,shock=rep(-1,10))
#
# Iran cut out of the World System for 30 years
#
x=IR_LM.fx
x[77:107,] <- 0
f <- simulate(W_IR,sampleT=250,noise=matrix(0,250,3),input=x)
tfplot(f)