# --------------------------------------- starts here
l <- 120 # # of months to predict
i <- seq ( 2, l/3,1) # seq of quarters to predict
d <- as.Date(as.yearqtr(seq(Sys.Date(),as.Date("2100-12-31"),by="quarters")[i])) # pick up the first day of each quarters.
r <- 1.05 # pesumed GDP growth rate
last ( PA); last( UC); last( GDP)
m_GDP <- as.xts(as.vector(last(GDP)) * r**(i/4),d)
m_PA <- (as.xts(forecast(auto.arima(PA),h=l)$mean[1:l],as.Date(as.yearmon(seq(mondate(index(last(PA)))+1,by=1,length.out=l))))[(3-month(index(last(PA))) %% 3) + seq(1,l-3,3)])[d]
m_UC <- (as.xts(forecast(auto.arima(UC),h=l)$mean[1:l],as.Date(as.yearmon(seq(mondate(index(last(UC)))+1,by=1,length.out=l))))[(3-month(index(last(UC))) %% 3) + seq(1,l-3,3)])[d]
my_sp5( m_GDP, m_PA, m_UC)
# --------------------------------------- ends here
> my_sp5( m_GDP, m_PA, m_UC)
[1] "m_mparams ! apply.quarter - UC w/ nominal GDP"
[,1]
2017-10-01 2584.017
2018-01-01 2677.548
2018-04-01 2767.463
2018-07-01 2855.281
2018-10-01 2942.127
2019-01-01 3028.843
2019-04-01 3116.057
2019-07-01 3204.248
2019-10-01 3293.780
2020-01-01 3384.937
2020-04-01 3477.938
2020-07-01 3572.961
2020-10-01 3670.150
2021-01-01 3769.625
2021-04-01 3871.485
d <- as.Date(as.yearqtr(seq(Sys.Date(),as.Date("2100-12-31"),by="quarters")[i])) # pick up the first day of each quarters.
r <- 1.05 # pesumed GDP growth rate
m_GDP <- as.xts(as.vector(last(GDP)) * r**(i/4),d)
m_PA <- (as.xts(forecast(auto.arima(PA),h=l)$mean[1:l],as.Date(as.yearmon(seq(mondate(index(last(PA)))+1,by=1,length.out=l))))[(3-month(index(last(PA))) %% 3) + seq(1,l-3,3)])[d]
m_UC <- (as.xts(forecast(auto.arima(UC),h=l)$mean[1:l],as.Date(as.yearmon(seq(mondate(index(last(UC)))+1,by=1,length.out=l))))[(3-month(index(last(UC))) %% 3) + seq(1,l-3,3)])[d]
my_sp5
# --------------------------------------- ends here
> my_sp5
[1] "m_m
[,1]
2017-10-01 2584.017
2018-01-01 2677.548
2018-04-01 2767.463
2018-07-01 2855.281
2018-10-01 2942.127
2019-01-01 3028.843
2019-04-01 3116.057
2019-07-01 3204.248
2019-10-01 3293.780
2020-01-01 3384.937
2020-04-01 3477.938
2020-07-01 3572.961
2020-10-01 3670.150
2021-01-01 3769.625
2021-04-01 3871.485
0 件のコメント:
コメントを投稿