Computes a Few Alternative Forecasts Based on Model Averaging.
Computes a Few Alternative Forecasts Based on Model Averaging.
It is necessary to compare a given forecast method with some alternative ones. This function computes selected forecast quality measures for a few selected forecast methods (which might be treated as alternative ones to Dynamic Model Averaging, Dynamic Model Selection, etc.).
ME (Mean Error), RMSE (Root Mean Squared Error), MAE (Mean Absolute Error), MPE (Mean Percentage Errror) and MAPE (Mean Absolute Percentage Error) are computed as accuracy. HR (Hit Ratio) is computed as hit.ratio.
y: numeric or a column matrix of a dependent variable
x: matrix of independent variables, different columns correspond to different independent variables
mods.incl: optional, matrix indicating which models will be used in averaging, if not specified all possible models will be used, see fDMA
gprob: optional, matrix of Google probabilities as in Koop and Onorante (2014), columns should correspond to columns of x, see fDMA
omega: optional, numeric, a parameter between 0 and 1 used in probabilities estimations, used if gprob is specified, see fDMA
av: optional, a method for model averaging, av="ord" corresponds to equal weights for each model, av="aic" corresponds to information theoretic model averaging based on Akaike Information Criterion, av="aicc" corresponds to information theoretic model averaging based on Akaike Information Criterion with a correction for finite sample sizes, av="bic" corresponds to information theoretic model averaging based on Bayesian Information Criterion, av="mse" corresponds to setting weights proportional to the inverse of the models Mean Squared Error, if not specified av="ord" is used
window: optional, numeric, a size of a rolling regression window (a number of observations), if not specified 10% of all observations are taken
initial.period: optional, numeric, a number of observation since which forecast quality measures are computed, if not specified the whole sample is used, i.e., initial.period=1, this argument also divides the sample into in-sample and out-of-sample for av. OLS method
d: optional, logical, a parameter used for HR (Hit Ratio) calculation, should be d=FALSE for level time-series and d=TRUE if time-series represent changes, if not specified d=FALSE
f: optional, logical vector, indicating which of alternative forecast -- av. OLS, av. rec. OLS, av. roll. OLS and av. TVP -- should be averaged, if not specified f=c(rep(TRUE,4), i.e., all alternative forecast are computed
fmod: optional, class dma object, a model to be compared with alternative forecast
parallel: optional, logical, indicate whether parallel computations should be used, by default parallel=FALSE
Details
For each av method, in the initial period equal weights for each model are taken, and then successively updated based on the chosen criterion. For OLS models weights are not updated. The same weight for each model (estimated from the in-sample period) is taken for each period.
If gprob is used, then for OLS mean values from the in-sample period are taken, for rec. OLS -- mean values from periods up to the current one, for roll. OLS -- mean values from the last window periods, and for TVP -- values from the current period.
Returns
class altf2 object, list of - $summary: matrix of forecast quality measures ordered by columns, forecast methods are ordered by rows
$y.hat: list of predicted values from all forecasting methods which were applied
$y: y, forecasted time-series
$coeff.: list of coefficients from all forecasting methods which were applied
$weights: list of weights of models used in averaging for all forecasting methods which were applied
$p.val.: list of p-values (averaged with respect to suitable weights) for t-test of statistical significance for coefficients from all forecasting methods which were applied (for TVP they are not computed)
$rel.var.imp.: list of relative variable importance from all forecasting methods which were applied
$exp.var.: list of expected number of variables (incl. constant) from all forecasting methods which were applied
Examples
wti <- crudeoil[-1,1]drivers <-(lag(crudeoil[,-1],k=1))[-1,]ld.wti <-(diff(log(wti)))[-1,]ld.drivers <- drivers[-1,]ld.drivers[,c(4,6)]<-(diff(drivers[,c(4,6)]))[-1,]ld.drivers[,c(1:2,5,7)]<-(diff(log(drivers[,c(1:2,5,7)])))[-1,]ld.drivers[,c(3,6)]<- ld.drivers[,c(3,6)]/100a1 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,initial.period=60)# compute just selected modelsfcomp <- c(TRUE,TRUE,TRUE,FALSE)a2 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,initial.period=60)a3 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,av="aic",initial.period=60)m1 <- fDMA(y=ld.wti,x=ld.drivers,alpha=0.99,lambda=0.90,initvar=10)a4 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,f=fcomp,fmod=m1,initial.period=60)# models just with one independent variable and a constant will be averagedmds <- diag(1,ncol(ld.drivers),ncol(ld.drivers))mds <- cbind(rep(1,ncol(ld.drivers)),mds)a5 <- altf2(y=ld.wti,x=ld.drivers,d=TRUE,mods.incl=mds,initial.period=60)# Google trends are available since 2004gp <- trends/100s1 <- ld.wti['2004-01-01/']s2 <- ld.drivers['2004-01-01/']a6 <- altf2(y=s1,x=s2,d=TRUE,gprob=gp,omega=0.5,initial.period=60)
References
Burnham, K. P., Anderson, D. R., 2004. Multimodel inference: Understanding AIC and BIC in model selection. Sociological Methods & Research 33 , 261--304.
Burnham, K. P., Anderson, D. R., 2002. Model Selection and Multimodel Inference: A Practical Information-Theoretic Approach, Springer.
Gelman, A., Hwang, J., Vehtari, A., 2014. Understanding predictive information criteria for Bayesian models. Statistics and Computing 24 , 997--1016.
Kapetanios, G., Labhard, V., Price, S., 2008. Forecasting using Bayesian and information-theoretic model averaging. Journal of Business & Economic Statistics 26 , 33--41.
Koop, G., Onorante, L., 2014. Macroeconomic nowcasting using Google probabilities. https://goo.gl/ATsBN9
Timmermann, A., 2006. Forecast combinations. In: Elliott, G., et al. (eds.), Handbook of Economic Forecasting, Elsevier.