# Dynamic Model Averaging in Economics and Finance with fDMA: A Package for R
## 8 Make Work Easier
#### 4.2.3 onevar(x)
If the outcomes come from the estimation of the rolling window regression, then the size of a rolling window is also printed. The second function additionally provides how often \(p\)-values for \(t\)-test of statistical significance for each explanatory variable in the model is below 1%, 5% and 10%, respectively. The third function allows to graphically present the outcomes. In particular:  
* residuals,
* regression coefficients on one plot, or in separate png files, saved in the current working directory, and moreover, to paste them into one big plot (also saved as png file in the current working directory),
* \(p\)-values for \(t\)-test of statistical significance for regression coefficients on one plot, or in separate png files, saved in the current working directory, and moreover, to paste them into one big plot (also saved as png file in the current working directory). R> summary(roll1) Mean coefficients: const MSCI TB3 MS CSP TWEXM PROD CONS VXO
0.0082 0.0108 0.3985 -0.1219 -0.4829 0.1848 -0.0628^0.0424  
Frequency when p-values for t-test are less than: const MSCI TB3 MS CSP TWEXM PROD CONS VXO
0.01 0.00 0.00 0.03 0.01 0.00 0.00 0.05 0.00
0.05 0.04 0.09 0.18 0.11 0.01 0.02 0.12 0.01
0.10 0.09 0.23 0.21 0.26 0.15 0.15 0.25^0.06  
RMSE: 0.0732 MAE: 0.0587 rolling window: 100 Sometimes it is necessary to consider various values of parameter window in rolling regression. The function grid.roll.reg computes a set of roll.reg functions for the given values of window. In other words, it is a wrapper of roll.reg allowing to quickly compute rolling regressions for various window sizes. grid.roll.reg(y, x = NULL, grid.window, parallel.grid = NULL, c = NULL)  
The arguments y, x and c are the same as the arguments for the function roll.reg. * grid.window should be a numeric vector indicating the different values of window argument for roll.reg. * parallel.grid is optional. This logical indicates whether parallel computations should be used. By default parallel.grid = FALSE is used. The outcomes are the object of class grid.roll.reg, i.e., a list of:  
* $models: a list of reg objects,
* $fq: a matrix with RMSE (Root Mean Squared Error) and MAE (Mean Absolute Error) for all estimated models. The outcomes can be easily presented with the help of functions print.grid.roll.reg, summary.grid.roll.reg and plot.grid.roll.reg. The first function prints RMSE (Root Mean Squared Error) and MAE (Mean Absolute Error) for all estimated models. The second function additionally finds the model minimizing RMSE and the model minimizing MAE. The third function allows to graphically present:  
* RMSE for all estimated models,
* MAE for all estimated models,
* the outcomes are saved in separate png files in the current working directory, and additionally, plots for different variables are collected into one big plot (also saved as png file in the current working directory),
* \(p\)-values for \(t\)-test of statistical significance for regression coefficients for all estimated models--the outcomes are saved in separate png files in the current working directory, and additionally, plots for different variables are collected into one big plot (also saved as png file in the current working directory). R> wti <- crudeoil[-1, 1] R> drivers <- (lag(crudeoil[, -1], k = 1))[-1, ] R> ld.wti <- (diff(log(wti)))[-1, ] R> ld.drivers <- (diff(log(drivers)))[-1, ] R> grw <- c(50,100,150) R> g <- grid.roll.reg(y = ld.wti, x = ld.drivers, grid.window = grw)  
R> model <- g$models[[2]]  
R> summary(g) RMSE MAE  
150 0.0761 0.0606
100 0.0732 0.0587
50 0.0717^0.0569  
The model minimising RMSE:The model minimising MAE:  
3  
In the above example, model is the extracted model with window = 100. The computational issues with Dynamic Model Averaging are not trivial. As a result, in case of the large number of models considered the outcomes of fDMA or grid.DMA function can be too big. If the information about each of the sub-model is not so important, then the function reduce.size can be useful.