# Dynamic Model Averaging in Economics and Finance with fDMA: A Package for R
## 8 Make Work Easier
Therefore, it can be desirable in certain cases, for computational reasons, to rescale variables to be between 0 and 1, i.e., normalize them. The function normalize does it. normalize(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 normalized 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 normalize. Then, the normalized sample is \(\tilde{x}=(\tilde{x}_{1},\ldots,\tilde{x}_{n})\), where  
\[\tilde{x}_{i}=\frac{x_{i}-\min_{i=1,\ldots,n}\{x_{i}\}}{\max_{i=1,\ldots,n}\{ x_{i}\}-\min_{i=1,\ldots,n}\{x_{i}\}}\]  
for all \(i=1,\ldots,n\). R> n <- normalize(_crudeoil_)  
On the other hand, sometimes normalization by rows of a matrix is desired. For example, Google Trends data are given as numbers between 0 and 100. If the user divides them by 100, they can be interpreted in a certain sense as probabilities [170]. However, if there are such probabilities for several variables, sometimes it might be desirable that these probabilities for all variables sum up to 1. The function gNormalize does not divide the values of an argument by 100, but rescales every row of the argument to sum up to 1. In other words, values in each row of the argument are divided by the sum of all values in this row. gNormalize(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. The outcomes are a matrix. R> gt <- gNormalize(trends)  
R> normalize(rbind(c(0, 1, 2), c(1, 2, 3)))  
[,1] [,2] [,3]  
[1,] 0 0 0  
[2,] 1 1 1  
R> gNormalize(rbind(c(0, 1, 2),c(1, 2, 3)))  
[,1] [,2] [,3]  
[1,] 0.000000 0.3333333 0.666667  
[2,] 0.1666667 0.333333 0.5000000 Actually, most R packages offering [PERSON]'s ARCH test require the argument to be of a specific class. This might be some kind of a problem for the user. On the other hand, the procedure of checking ARCH effects is very common and can also be useful during DMA research. The function architects computes [PERSON]'s ARCH test [185]. The null hypothesis of this Lagrange Multiplier test is that a series of residuals exhibits no ARCH effects. The alternative hypothesis is that ARCH(lag) effects are present. The argument lag is specified by the user. In particular, let \(y_{t}\) be the time-series, \(t=1,\ldots,n\), in which ARCH effects of lag \(p\) are suspected. The test procedure is the following. First, the linear regression is estimated \(y_{t}=a+\epsilon_{t}\), and \(\epsilon_{t}\) are derived. Next, the below linear regression is estimated  
\[(\epsilon_{t})^{2}=a_{0}+a_{1}(\epsilon_{t-1})^{2}+\ldots+a_{p}(\epsilon_{t-p} )^{2}+\xi_{t}\quad. \tag{27}\]  
The test statistic is \(R^{2}\cdot(n-p)\), where \(R^{2}\) is R-squared coefficient of the linear regression model given by Equation (27). This statistic has the \(\chi^{2}\) distribution with \(p\) degrees of freedom. archest(ts, lag = NULL)  
The arguments for this function are the following:  
* ts should be a vector representing the tested time-series,
* lag is optional. This numeric represents the suspected order of ARCH process, i.e., \(p\) from the above considerations. If not specified, then lag = 1 is taken. The outcomes are a class htest object, i.e., a list of:  
* statistic: the test statistic,
* parameter: the argument lag used in the test,
* alternative: the alternative hypothesis of the test,
* \(p\).value: \(p\)-value of the test,
* method: the name of the test,
* data.name: the name of the tested time-series. Because the outcomes are a class htest object, they can be presented in the standard way.