#
# FR_L20 BAU R code (cut and paste into the window above)
#
#
# Measurement Matrix (Growth), (CO2+EF), (LU-L-N)
#
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD SL.TLF.TOTL.IN SP.POP.TOTL
#[1,] 0.004201 0.3740 0.3762 0.369 0.3742
#[2,] 0.781330 0.0959 -0.0379 -0.059 -0.0241
#[3,] 0.000453 0.0585 -0.1871 -0.355 -0.2225
# SL.UEM.TOTL.ZS KOF EF HDI
#[1,] 0.3299 0.3643 0.2460 0.3748
#[2,] -0.0912 -0.1994 0.5658 -0.0815
#[3,] 0.8719 0.0366 0.0632 -0.1437
#
#Fraction of Variance
#[1] 0.774 0.947 0.980 0.995 0.998 0.999 1.000 1.000 1.000
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
f <- matrix( c(1.00000000, 0.000000000, 0.000000000, 0.00000000,
0.15899897, 0.978259124, -0.007089443, 0.03754641,
0.03662640, -0.056082476, 0.873913184, -0.08591339,
-0.01438929, -0.007292328, 0.035524512, 0.98396398
),byrow=TRUE,nrow=4,ncol=4)
h <- matrix(c(0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
),byrow=TRUE,nrow=3,ncol=4)
q <- matrix(c(0.00000000, 0.00000000, 0.0000000000,
0.09939021, -0.01340639, -0.0007502257,
0.33144184, 0.21400487, 0.0036547179,
-0.01919784, -0.08548604, 0.1012289972
),byrow=TRUE,nrow=4,ncol=3)
k <- matrix(c(0.57211989, -0.05756551, 0.05685718,
-1.3790314, 0.65909624, -0.14091064,
-0.05981689, -0.04805524, 0.83677834,
0.00000000, 0.00000000, 0.00000000
),byrow=TRUE,nrow=4,ncol=3)
r <- matrix(c(0.123444975, 0.00000000, 0.0000000,
0.379899380, 0.24753422, 0.0000000,
0.008949194, -0.06526614, 0.1028788
),byrow=TRUE,nrow=3,ncol=3)
FRL20i <- SS(F=f,H=h,K=k,z0=c(1.00000000, -5.09257209, -2.91481894, 0.07210822),
output.names=c("FR1","FR2","FR3"))
FRL20 <- SS(F=f,H=h,Q=q,R=r,z0=c(1.00000000, -5.09257209, -2.91481894, 0.07210822),
output.names=c("FR1","FR2","FR3"))
print(FRL20)
is.SS(FRL20)
stability(m<-SS(F=f[2:4,2:4,drop=FALSE],Q=eye(3,3),R=eye(3,3),H=eye(3,3)))
# tfplot(simulate(m,sampleT=50,start=1960))
FRL20.data <- simulate(FRL20i,sampleT=50,noise=matrix(0,50,3),start=1960)
FRL20.f <- forecast(m <- l(FRL20,FRL20.data),horizon=50)
print("(Growth), (CO2+EF), (LU-L-N)")
shockDecomposition(m)
tfplot(FRL20.f)