# VARX Fit/Filter/Forecast/Simulation Functions

### Description

Vector Autoregressive (VAR) with Constant and Optional Exogenous Regressors (X) Fit, Filter, Forecast and Simulation functions for use with multivariate GARCH models.

### Usage

1 2 3 4 5 | ```
varxfit(X, p, exogen = NULL, robust = FALSE, gamma = 0.25, delta = 0.01, nc = 10,
ns = 500, postpad = c("none", "constant", "zero", "NA"), cluster = NULL)
varxfilter(X, p, Bcoef, exogen = NULL, postpad = c("none", "constant", "zero", "NA"))
varxforecast(X, Bcoef, p, out.sample, n.ahead, n.roll, mregfor)
varxsim (X, Bcoef, p, n.sim, n.start, prereturns, resids, mexsimdata)
``` |

### Arguments

`X` |
A multivariate data matrix. |

`p` |
The number of autoregressive lags. |

`exogen` |
An optional matrix of exogenous regressors with as many rows as X, and appropriately lagged. |

`Bcoef` |
A matrix of coefficients for the varxfilter function. |

`robust` |
Whether to use the robust version of VAR based on the multivariate Least Trimmed Squares Estimator described in Croux and Joossens (2008). |

`gamma` |
Proportion to trim in the robust method. |

`delta` |
The critical value for Reweighted estimator for the robust method. |

`ns` |
The number of subsets to use for the robust method. |

`nc` |
The number of C-steps to use for the robust method. |

`postpad` |
(defaults to ‘none’) Whether to postpad the fitted/filtered values (and hence calculation of residuals) with the estimated constant, zeros or NA's, thus returning matrices of the same size as the input data (rather than input data size less the number of lags). |

`cluster` |
A cluster object created by calling |

`out.sample` |
The number of points kept for out of sample rolling forecast. |

`n.ahead` |
The forecast horizon. |

`n.roll` |
In combination with |

`mregfor` |
Matrix of external regressor forecasts (with appropriate lag structure). |

`n.sim` |
Simulation horizon. |

`n.start` |
Simulation burn-in sample. |

`prereturns` |
Optionally supplied pre-return matrix with “p” lags to initialize simulation. |

`resids` |
Matrix of randomly generated residuals of size n.sim+n.start. |

`mexsimdata` |
Matrix of external regressor pre-generated random values to use in the simulation (if NULL then assumed zero). |

### Details

This are convenience functions to be optionally used when using the multivariate GARCH methods.

### Value

A list with the following items:

`Bcoef ` |
[varxfit, varxfilter] |

`xfitted ` |
[varxfit, varxfilter] |

`xresiduals ` |
[varxfit, varxfilter] |

`Bcov ` |
[varxfit] |

`se ` |
[varxfit] |

`tstat ` |
[varxfit] |

`pstat ` |
[varxfit] |

`lag ` |
[varxfit, varxfilter] |

`mxn` |
[varxfit] |

`meansim` |
[varxsim] |

The varxsim returns an n.sim x n.asset matrix of the simulated conditional
means, while the varxforecast returns an n.ahead x n.assets x (n.roll+1) array
of the forecast conditional means.

### Note

Part of the varxfit functionality and structure is inspired from the 'vars'
package, but the estimation method is implemented in a very quick way without
calling 'lm'. The robust method is based on the matlab program of Christophe
Croux available from his website and the option of using parallel computation is
implemented for this particular choice.The `postpad`

option is used when the
returned data needs to be of the same size as the inputed data for easier
manipulation/comparison (since padding is done post-estimation, there is no bias
introduced during estimation).

### Author(s)

Alexios Ghalanos

### References

Lutkepohl, H. 2005, New introduction to multiple time series analysis,
*Springer*.

Croux, C. and Joossens, K. 2008, Robust estimation of the vector autoregressive
model by a least trimmed squares procedure, *COMPSTAT*, 489–501.