fDMA: Computes Dynamic Model Averaging.

fDMAR Documentation

Computes Dynamic Model Averaging.

Description

The function estimates Dynamic Model Averaging (and some of its variations). The method is described in Raftery et al. (2010).

Usage

fDMA(y,x,alpha,lambda,initvar,W=NULL,initial.period=NULL,V.meth=NULL,kappa=NULL,
gprob=NULL,omega=NULL,model=NULL,parallel=NULL,m.prior=NULL,mods.incl=NULL,
DOW=NULL,DOW.nmods=NULL,DOW.type=NULL,DOW.limit.nmods=NULL,progress.info=NULL,
forced.models=NULL,forbidden.models=NULL,forced.variables=NULL,bm=NULL,
small.c=NULL,fcores=NULL,mods.check=NULL,red.size=NULL,av=NULL)

Arguments

y

numeric or a column matrix of a dependent variable, if y is xts object, then plots will have time index on the x axis

x

matrix of independent variables, different columns correspond to different variables

alpha

numeric, a forgetting factor \alpha between 0 and 1 used in probabilities estimations

lambda

numeric, a forgetting factor \lambda between 0 and 1 used in variance approximations

initvar

numeric, initial variance in the state space equation, i.e., the number by which the unit matrix is multiplied

W

optional, a method for setting the initial values of variance for the models equations, W="reg" corresponds to the method based on the linear regression as in the paper by Raftery et al. (2010), alternatively an arbitrary positive number (numeric) can be specified, by default the method of Raftery et al. (2010) is used

initial.period

optional, numeric, a number of observation since which MSE (Mean Squared Error) and MAE (Mean Absolute Error) are computed, by default the whole sample is used, i.e., initial.period=1

V.meth

optional, a method for the state space equation variance updating, V.meth="rec" corresponds to the recursive moment estimator, as in the paper by Raftery et al. (2010), V.meth = "ewma" corresponds to the exponentially weighted moving average as in, for example, Koop and Korobilis (2012), by default V.meth = "rec" is used

kappa

optional, numeric, a parameter in the exponentially weighted moving average, between 0 and 1, used if V.meth = "ewma"

gprob

optional, matrix of Google probabilities as in Koop and Onorante (2014), columns should correspond to columns of x

omega

optional, numeric, a parameter between 0 and 1 used in probabilities estimations, used if gprob is specified

model

optional, model="dma" for Dynamic Model Averaging, model="dms" for Dynamic Model Selection, or model="med" for Median Probability Model as in Barbieri and Berger (2004), by default model="dma" is used

parallel

optional, logical, indicate whether parallel computations should be used, by default parallel=FALSE

m.prior

optional, numeric, a parameter for general model prior (Mitchell and Beauchamp, 1988), by default m.prior=0.5, which corresponds to the uniform distribution, i.e., non-informative priors, see also Eicher et al. (2011)

mods.incl

optional, matrix indicating which models should be used for estimation, the first column indicates inclusion of a constant, by default all possible models with a constant are used, inclusion of a variable is indicated by 1, omitting by 0

DOW

optional, numeric, a threshold for Dynamic Occam's Window (Onorante and Raftery, 2016), should be a number between 0 and 1, if DOW=0, then no Dynamic Occam's Window is applied, by default DOW=0, Dynamic Occam's Window can be applied only to Dynamic Model Averaging, i.e., when model="dma"

DOW.nmods

optional, numeric, initial number of models for Dynamic Occam's Window, should be less than the number of all possible models and larger than or equal to 2, they are randomly chosen, if DOW.nmods=0, then initially models with exactly one variable are taken, by default DOW.nmods=0

DOW.type

optional, DOW.type="r" corresponds to DMA-R from Onorante and Raftery (2016), DOW.type="e" to DMA-E, by default DOW.type="r"

DOW.limit.nmods

optional, numeric, maximum number of models selected by Dynamic Occam's Window, an additional limitation to the threshold given by DOW, by default no limit is set

progress.info

optional, logical, applicable only if Dynamic Occam's Window is used, otherwise ignored, if progress.info=TRUE number of the current recursive DMA computation round and number of models selected for this round are printed, by default progress.info=FALSE

forced.models

optional, matrix, applicable only if Dynamic Occam's Window is used, otherwise ignored, indicates models that have to be always included in the set of expanded models, similar as mods.incl, by default forced.models=NULL

forbidden.models

optional, matrix, applicable only if Dynamic Occam's Window is used, otherwise ignored, indicates models that cannot be used in the set of expanded models, similar as mods.incl, by default forbidden.models=NULL

forced.variables

optional, vector, applicable only if Dynamic Occam's Window is used, otherwise ignored, indicates variables that have to be always included in models constituting the set of expanded models, similar as mods.incl, first slot indicates inclusion of constant, by default forced.variables=NULL

bm

optional, logical, indicate whether benchmark forecast should be computed, these benchmarks are naive forecast (all forecasts are set to be the value of the last observation) and Auto Arima auto.arima, by default bm=FALSE

small.c

optional, numeric, small constant added to posterior model proabilities as in Raftery et al. (2010) to prevent potential reduction them to 0 due to the computational issues, if not specified the value computed as in Raftery et al. (2010) is taken

fcores

optional, numeric, used only if parallel=TRUE, otherwise ignored, indicates the number of cores that should not be used, by default fcores=1

mods.check

optional, logical, indicates if mods.incl should be checked for duplicated entries, etc., by default mods.check=FALSE

red.size

optional, logical, indicates if outcomes should be reduced to save memory, by default red.size=FALSE

av

optional, av="dma" corresponds to the original DMA averaging scheme, av="mse" corresponds to averaging based on Mean Squared Error, av="hr1" corresponds to averaging based on Hit Ratio, assuming time-series are in levels, av="hr2" corresponds to averaging based on Hit Ratio, assuming time-series represent changes, by default av="dma"

Details

It is possible to use numeric vector for lambda. Its values are automatically ordered in descending order and if numbers are not unique they are reduced to become unique. If more than one value is given for lambda, then model state space, i.e., mods.incl, is expanded by considering all these models with given values of lambda. The outcomes are then ordered by columns in a way that first outcomes from models with first value of lambda are presented, then from models with second value of lambda, etc. (Raftery et al., 2010).

If nrow(gprob)<length(y), then the method by Koop and Onorante (2014) is used for the last nrow(gprob) observations. For the preceding ones the original method by Raftery et al. (2010) is used. In such case a warning is generated.

Value

class dma object, list of

$y.hat

forecasted values

$post.incl

posterior inclusion probabilities for independent variables

$MSE

Mean Squared Error of forecast

$MAE

Mean Absolute Error of forecast

$models

models included in estimations, or models used in the last step of Dynamic Occam's Window method (if this method has been selected)

$post.mod

posterior probabilities of all used models, or NA if Dynamic Occam's Window method has been selected

$exp.var

expected number of variables (incl. constant)

$exp.coef.

expected values of regression coefficients

$parameters

parameters of the estimated model

$yhat.all.mods

predictions from every sub-model used in estimations

$y

y, dependent variable

$benchmarks

Root Mean Squared Error and Mean Absolute Error of naive and auto ARIMA forecast

$DOW.init.mods

models initially selected to Dynamic Occam's Window, if this method has been selected

$DOW.n.mods.t

number of models used in Dynamic Model Averaging at time t, if Dynamic Occam's Window method has been selected

$p.dens.

predicitive densities from the last period of all sub-models used in estimations

$exp.lambda

expected values of lambda parameter

Source

Raftery, A. E., Karny, M., Ettler, P., 2010. Online prediction under model uncertainty via Dynamic Model Averaging: Application to a cold rolling mill. Technometrics 52, 52–66.

References

Barbieri, M. M., Berger, J. O., 2004. Optimal predictive model selection. The Annals of Statistics 32, 870–897.

Eicher, T. S., Papageorgiou, C., Raftery, A. E., 2011. Default priors and predictive performance in Bayesian Model Averaging, with application to growth determinants. Journal of Applied Econometrics 26, 30–55.

Koop, G., Korobilis, D., 2012. Forecasting inflation using Dynamic Model Averaging. International Economic Review 53, 867–886.

Koop, G., Korobilis, D., 2018. Variational Bayes inference in high-dimensional time-varying parameter models. https://arxiv.org/pdf/1809.03031

Koop, G., Onorante, L., 2014. Macroeconomic nowcasting using Google probabilities. https://goo.gl/ATsBN9

Mitchell, T. J., Beauchamp, J. J., 1988. Bayesian variable selection in linear regression (with discussion). Journal of the American Statistical Association 83, 1023–1036.

Onorante, L., Raftery, A. E., 2016. Dynamic model averaging in large model spaces using dynamic Occam's window. European Economic Review 81, 2–14.

Yin, X., Peng, J., Tang, T., 2018. Improving the forecasting accuracy of crude oil prices. Sustainability 10, 454. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.3390/su10020454")}

See Also

grid.DMA, print.dma, summary.dma, plot.dma, hit.ratio.

Examples

wti <- crudeoil[-1,1]
drivers <- (lag(crudeoil[,-1],k=1))[-1,]
ld.wti <- (diff(log(wti)))[-1,]
ld.drivers <- (diff(log(drivers)))[-1,]

m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10)
m2 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,model="dms")
m3 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,V.meth="ewma",kappa=0.9)
m4 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,DOW=0.7)


# Google trends are available since 2004

gp <- trends/100
s <- ld.drivers['2004-01-01/']
m5 <- fDMA(y=ld.wti['2004-01-01/'],x=s,alpha=0.99,lambda=0.90,initvar=10,gprob=gp,omega=0.5)


# models just with one independent variable and a constant will be averaged
mds <- diag(1,ncol(ld.drivers),ncol(ld.drivers))
mds <- cbind(rep(1,ncol(ld.drivers)),mds)

m6 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,mods.incl=mds)


# models just with one independent variable (without a constant) will be averaged
mds.nc <- diag(1,ncol(ld.drivers),ncol(ld.drivers))
mds.nc <- cbind(rep(0,ncol(ld.drivers)),mds.nc)

m7 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10,mods.incl=mds.nc)

# model with multiple lambda

m8 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=c(0.99,0.95,0.90),initvar=10)


fDMA documentation built on July 26, 2023, 6:09 p.m.

Related to fDMA in fDMA...