# Dynamic Model Averaging in Economics and Finance with fDMA: A Package for R
## 8 Make Work Easier  
In the fDMA package also a few additional functions were implemented, which can be of a general use/interest. The motivation behind this decision was just to include in the package important tools, and let the user have it at hand with no necessity to search for them in other packages or write such functions by his or her own. The function descstat is simply a wrapper of the function describe from the package psych by [PERSON] [21]. This function computes selected descriptive statistics which are quite useful to see before performing Dynamic Model Averaging. descstat(data)The argument for this function, data, should be a matrix. The observations should be put in rows, and variables should be grouped by columns. If the argument is not a matrix, the function tries to convert the object into a matrix. For example, it works smoothly for xts objects. The outcomes are a matrix with:  
* mean,
* standard deviation,
* variance,
* median,
* minimum value,
* maximum value,
* skewness, i.e., \(\frac{(n-1)^{\frac{3}{2}}}{n}\frac{\sum_{i=1}^{n}(x_{i}-x)^{3}}{\left(\sum_{i=1 }^{n}(x_{i}-x)^{2}\right)^{\frac{3}{2}}}\),
* kurtosis, i.e., \(\frac{(n-1)^{2}}{n}\frac{\sum_{i=1}^{n}(x_{i}-x)^{4}}{\left(\sum_{i=1}^{n}(x_{i }-x)^{2}\right)^{2}}-3\),
* coefficient of variation. In the above formulas \(\tilde{x}\) denotes the mean of the sample, \(n\) - the number of observations in the sample. The sample is given by \(x=(x_{1},\ldots,x_{n})\). Skewness is computed with a natural method of moments estimator, i.e., as the sample third central moment divided by the third power of the sample standard deviation. Kurtosis is computed as the sample fourth central moment divided by the the fourth power of the sample standard deviation and this is lessen by 3. Their properties are discussed by [PERSON] and [PERSON] [184]. R> t(descstat(crudeoil[, 1:3])) WTI MSCI TB3 MS mean 46.64500 1082.97500 2.82200 sd 30.51700 379.83900 2.29900 variance 931.28300 144277.32900 5.28500 median 32.64000 1091.68000 2.99000 min 11.35000 423.14000 0.01000 max 133.90000 1779.30000 7.90000 skew 0.78767 0.02822 0.14938 kurtosis -0.67540 -1.04620 -1.31570 coeff. of variation 1.52800 2.85100 1.22700  
It is a very common situation that one needs to have all variables to have mean 0 and standard deviation 1. The function standardize rescales the values in such a way, i.e., standardizes them. standardize(data)  
The argument for this function, data, should be a matrix. The observations should be put in rows, and variables should be grouped by columns. If the argument is not a matrix, the function tries to convert the object into a matrix. For example, it works smoothly for xts objects. The outcomes are a matrix of the standardized data. The structure of argument data is kept, i.e., the observations are in rows, and variables are grouped by columns. In particular, let \(x=(x_{1},\ldots,x_{n})\) be the sample one wants to standardize. Then, the standardized sample is \(\tilde{x}=(\tilde{x}_{1},\ldots,\tilde{x}_{n})\), where  
\[\tilde{x}_{i}=\frac{x_{i}-\mu(x)}{\sigma(x)}\]  
for all \(i=1,\ldots,n\). \(\mu(x)\) denotes mean of the sample \(x\) and \(\sigma(x)\) standard deviation of the sample \(x\). R> s<- standardize(crudeoil)It was mentioned that in order to estimate DMA some initial parameters have to be set by the user. One of such parameters is initvar in the function fDMA, which represent the initial values of variances in the state space equation, \(V_{0}^{(k)}\). As many models have to be estimated, these values have to correspond in some sense to the explanatory variables used in these models. Indeed, it represents in a certain sense the degree of instability of parameters in the models - how high volatility of them is assumed by the user. The problem becomes complicated if explanatory variables are of significantly different magnitudes. On the other hand, it is simple if their magnitudes are similar. For example, if all explanatory variables are between 0 and 1, then setting \(V_{0}^{(k)}=1\) is a reasonable choice.