# Dynamic Model Averaging in Economics and Finance with fDMA: A Package for R
## 4 Fundamental Functions  
In this section the main functions of fDMA are described. The main function in this package is fDMA. It should be used in the following way. 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)  
Below the arguments for this function are explained:  
* y should be a numeric or a column matrix representing the dependent variable. If it is xts, then plots will have time index on the \(x\) axis,
* x should be a matrix of explanatory variables. Observations should go by rows, and different columns should correspond to different variables,
* alpha should be a numeric representing the forgetting factor \(\alpha\) used in Equation (2),
* lambda should be a numeric representing the forgetting factor \(\lambda\) used in Equation (4), It is also possible to specify lambda as numeric vector. Then, its values are automatically ordered in descending order, and if numbers are not unique they are reduced to become unique. The idea is that if more than one value is given for lambda, then the model state space, i.e., mods.incl, is expanded by considering all these models with given values of lambda. The outcomes of fDMA 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. This specification can be used if the user would like to perform the model combination scheme in which models specified by mods.incl are additionally treated as separate new models each with different value of \(\lambda\) given by lambda. Such an approach is given by [PERSON] et al. [1] at the end of their paper,
* initvar should be a numeric. It represents the initial variances in the state space equation, \(V_{0}^{(k)}\). It is taken the same for all \(k=1,\ldots,K\) models,
* W is optional. If W = \"reg\" then \(E_{0}^{(k)}\) are specified in the initial step as in Equation (13). On the other hand, if a positive numeric is given, then Equation (13) is modified in the following way: \[E_{0}^{(k)}=\left[ \begin{array}{cccc}W&0&\ldots&0\\ 0&W&\ldots&0\\ \vdots&\vdots&\ddots&0\\ 0&\ldots&\ldots&W\end{array} \right]\quad.\] By default W = \"reg\",
* initial.period is optional. This numeric indicates since which moment MSE (Mean Squared Error) and MAE (Mean Absolute Error) should be computed. As fDMA already produces some forecast quality measures, the user might require to treat some first observations as \"training period\". By default the whole sample is used to produce forecast quality measures, i.e., initial.period = 1,
* V.meth is optional. If V.meth = \"rec\", then the recursive moment estimator as in Equation (7) is used. If V.meth = \"ewma\", then the exponentially weighted moving average (EWMA) is used, i.e., Equation (7) is replaced by \[V_{t}^{(k)}=\kappa\cdot\hat{V}_{t-1}^{(k)}+(1-\kappa)\cdot(e_{t}^{(k)})^{2}\quad,\] (20) where \(\kappa\) (kappa) has to be also specified. EWMA is a common estimator in finance. For instance, Riskmetrics calls \(\kappa\) a _decay factor_ and suggests \(\kappa=0.97\) for monthly data, and \(\kappa=0.94\) for daily data. [PERSON] and [PERSON] [157] used \(\kappa=0.98\) for quarterly data. EWMA was also used by them when ARCH effects in Equation (1) were suspected, as other methods would increase the computational burden too much. By default V.meth = \"rec\" is used,
* kappa is optional numeric. It has to be specified if V.meth = \"ewma\". Then, it corresponds to \(\kappa\) in Equation (20),* gprob is optional. This matrix represents Google probabilities, \(g_{i,t}\), as in (17). In other words, columns should correspond to different explanatory variables, i.e., the columns of x.