model.MRW: The Multivariate Random Walk Model

Description Usage Arguments Details Value Author(s) Source References Examples

View source: R/model_MRW.R

Description

Fit a Multivariate Random Walk Model to the input data, a multivariate time series.

Usage

1
2
model.MRW(data, x = NULL, y = NULL, include.drift = TRUE,
  lowess.smooth = TRUE, ...)

Arguments

data

Numeric matrix with a multivariate time series. Series are arranged in rows with columns representing time.

x

Numerical vector indicating the age classes in input data. Optional. This is used to label the output tables and related plots. Default: NULL.

y

Numerical vector indicating the years in input data. Optional. This is used to label the output tables and related plots. Default: NULL.

include.drift

Should the Random Walk model include a linear drift term? Default: TRUE.

lowess.smooth

Logical. Should the estimatated vector of drift parameters be smoothed using a lowess function? Default: TRUE. This helps avoiding highly divergent trends between time-series when the model is used to do predictions.

...

Arguments to be passed to or from other methods.

Details

For further information on the Multivariate Random Walk with drift see Appendix B in \insertCitehaberman2011;textualMortalityForecast.

Value

An object of class MRW with components:

input

A list with the input data;

info

Short details about the model;

call

An unevaluated function call, that is, an unevaluated expression which consists of the named function applied to the given arguments;

coefficients

A vector with the estimated drift parameters;

fitted.values

Fitted values of the estimated model;

observed.values

The observed values used in fitting arranged in the same format as the fitted.values;

residuals

Residuals from the fitted model. That is observed minus fitted values;

sigma

A matrix with the estimated variance covariance matrix;

x

Vector of ages used in fitting;

y

Vector of years used in fitting.

Author(s)

Marius D. Pascariu

Source

The original implementation of this function was taken from StMoMo R package.

References

\insertAllCited

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Forecast mortality using a Multivariate Random Walk with Drift model
x  <- 0:100
y  <- 1980:2000
mx <- HMD_male$mx$GBRTENW[paste(x), paste(y)]

M <- model.MRW(data = log(mx), x = x, y = y, include.drift = TRUE)
P <- predict(M, h = 16)
R <- residuals(M)

pv <- exp(P$predicted.values)
matplot(pv, type = "l", log = "y")
matplot(t(pv), type = "l", log = "y")

mpascariu/MortalityForecast documentation built on Sept. 28, 2020, 2:40 p.m.