Description Usage Arguments Details Value Examples
View source: R/forecastfitStMoMo.R
Forecast mortality rates using a Stochastic Mortality Model fit. The period indexes κ_t^{(i)}, i = 1,..N, are forecasted using ether a Multivariate Random Walk with Drift (MRWD) or N independent ARIMA(p, d, q) models. The cohort index γ_{t-x} is forecasted using an ARIMA(p, d, q). By default an ARIMA(1, 1, 0) with a constant is used.
1 2 3 4 5 6 |
object |
an object of class |
h |
number of years ahead to forecast. |
level |
confidence level for prediction intervals of the period and cohort indices. |
oxt |
optional matrix/vector or scalar of known offset to be added in the forecasting. This can be used to specify any a priori known component to be added to the forecasted predictor. |
gc.order |
a specification of the ARIMA model for the cohort effect: the three components (p, d, q) are the AR order, the degree of differencing, and the MA. The default is an ARIMA(1, 1, 0). |
gc.include.constant |
a logical value indicating if the ARIMA model
should include a constant value. The default is |
jumpchoice |
option to select the jump-off rates, i.e. the rates
from the final year of observation, to use in projections of mortality
rates. |
kt.method |
optional forecasting method for the period index.
The alternatives are |
kt.order |
an optional matrix with one row per period index
specifying the ARIMA models: for the ith row (ith period index) the three
components (p, d, q) are the AR order, the degree of differencing,
and the MA order. If absent the arima models are fitted using
|
kt.include.constant |
an optional vector of logical values
indicating if the ARIMA model for the ith period index should include a
constant value. The default is |
kt.lookback |
optional argument to specify the look-back window to use
in the estimation of the time series model for the period indexes. By
default all the estimated values are used. If
|
gc.lookback |
optional argument to specify the look-back window to use
in the estimation of the ARIMA model for the cohort effect. By
default all the estimated values are used in estimating the ARIMA
model. If |
... |
other arguments for |
If kt.method
is "mrwd"
, fitting and forecasting of
the time series model for the period indexes is done with a
Multivariate Random Walk with Drift using the function
mrwd
.
If kt.method
is "iarima"
, fitting and forecasting of
the time series model for the period indexes is done with N
independent arima models using the function iarima
.
See this latter function for details on input arguments
kt.order
and kt.include.constant
.
Fitting and forecasting of the ARIMA model for the cohort index
is done with function Arima
from package
forecast. See the latter function for further details on
input arguments gc.order
and gc.include.constant
.
Note that in some cases forecast of the cohort effects may be
needed for a horizon longer than h
. This is the case when
in the fitted model the most recent cohorts have been zero weighted.
The forecasted cohorts can be seen in gc.f$cohorts
.
A list of class "forStMoMo"
with components:
rates |
a matrix with the point forecast of the rates. |
ages |
vector of ages corresponding to the rows of |
years |
vector of years for which a forecast has been produced. This
corresponds to the columns of |
kt.f |
forecasts of period indexes of the model. This is a list with
the |
gc.f |
forecasts of cohort index of the model. This is a list with
the |
oxt.f |
the offset used in the forecast. |
fitted |
a matrix with the fitted in-sample rates of the model for the years for which the mortality model was fitted. |
model |
the model fit from which the forecast was produced. |
jumpchoice |
Jump-off method used in the forecast. |
kt.method |
method used in the forecast of the period index. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #Lee-Carter (random walk with drift)
LCfit <- fit(lc(), data = EWMaleData, ages.fit = 55:89)
LCfor <- forecast(LCfit)
plot(LCfor)
#Lee-Carter (forecast with ARIMA(1,1,2) with drift )
LCfor.iarima1 <- forecast(LCfit, kt.method = "iarima", kt.order = c(1, 1 , 2))
plot(LCfor.iarima1)
#Lee-Carter (forecast with auto.arima)
LCfor.iarima2 <- forecast(LCfit, kt.method = "iarima")
plot(LCfor.iarima2)
#CBD (Multivariate random walk with drift)
CBDfit <- fit(cbd(), data = central2initial(EWMaleData), ages.fit = 55:89)
CBDfor <- forecast(CBDfit)
plot(CBDfor, parametricbx = FALSE)
#CBD (Independent Arima models)
kt.order <- matrix(c(1, 1, 2, #ARIMA(1, 1, 2) for k[1]
0, 1, 1), #ARIMA(0, 1, 1) for k[2]
nrow = 2, ncol = 3, byrow = TRUE)
CBDfor.iarima <- forecast(CBDfit, kt.method = "iarima", kt.order = kt.order)
plot(CBDfor.iarima, parametricbx = FALSE)
#APC: Compare forecast with different models for the cohort index
wxt <- genWeightMat(55:89, EWMaleData$years, clip = 3)
APCfit <- fit(apc(), data = EWMaleData, ages.fit = 55:89,
wxt = wxt)
APCfor1 <- forecast(APCfit)
plot(APCfor1, parametricbx = FALSE, nCol = 3)
APCfor2 <- forecast(APCfit, gc.order = c(0, 2, 2))
plot(APCfor2, only.gc = TRUE)
plot(c(APCfit$years, APCfor1$years),
cbind(APCfor1$fitted, APCfor1$rates)["65", ],
type = "l", xlab = "year", ylab = "Mortality rate at age 65",
main = "Forecasts with different models for gc")
lines(APCfor2$years, APCfor2$rates["65", ], col = "blue")
points(APCfit$years, (APCfit$Dxt / APCfit$Ext)["65", ], pch = 19)
#Compare Lee-Carter forecast using:
# 1. Fitted jump-off rates and all history for kt
# 2. Actual jump-off rates and all history for kt
# 3. Fitted jump-off rates and only history for
# the past 30 years of kt (i.e 1982-2011)
LCfor1 <- forecast(LCfit)
LCfor2 <- forecast(LCfit, jumpchoice = "actual")
LCfor3 <- forecast(LCfit, kt.lookback = 30)
plot(LCfit$years, (LCfit$Dxt / LCfit$Ext)["60", ],
xlim = range(LCfit$years, LCfor1$years),
ylim = range((LCfit$Dxt / LCfit$Ext)["60", ], LCfor1$rates["60", ],
LCfor2$rates["60", ], LCfor3$rates["60", ]),
type = "p", xlab = "year", ylab = "rate",
main = "Lee-Carter: Forecast of mortality rates at age 60")
lines(LCfit$years, fitted(LCfit, type = "rates")["60", ])
lines(LCfor1$years, LCfor1$rates["60", ], lty = 2)
lines(LCfor2$years, LCfor2$rates["60", ], lty = 3, col = "blue")
lines(LCfor3$years, LCfor3$rates["60", ], lty = 4, col = "red")
legend("topright",legend = c("Fitted jump-off", "Actual jump-off",
"Fitted jump-off, 30 year look-back"),
lty = 1:3, col = c("black", "blue", "red"))
|
Loading required package: gnm
Loading required package: forecast
StMoMo: Start fitting with gnm
Initialising
Running start-up iterations..
Running main iterations.....
Done
StMoMo: Finish fitting with gnm
StMoMo: Start fitting with gnm
StMoMo: Finish fitting with gnm
StMoMo: The following cohorts have been zero weigthed: 1872 1873 1874 1954 1955 1956
StMoMo: Start fitting with gnm
StMoMo: Finish fitting with gnm
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.