arch
arch copied to clipboard
ENH: allow exogenous variable to be numpy 2-d array
Hi,
I'd like to suggest that the forecast
method of the arch model result be capable of accepting exogenous variables as (horizon, scenario), 2d numpy array. Right now, the solution with a for-loop for every scenario x does not take advantage of matrix multiplication that can be done more efficiently:
$$ y_{t+1, i_scenario} = \beta 1_{i_scenario, j_scenario} x_{t+1, j_scenario} + \ldots $$
and this slows down computations considerably for someone calculating simulations for several paths and several time-series $y_t$ for a single task, say if one wants to look at several risk factors that have an exogenous systemic risk factor.
This would be useful if the output includes y_t for each scenario (not only unconditional means).
This can't work since exogenous variables are already 2d since AR-X can have multiple X, and so you have to be able to pass 2-d for specify the values of all X's. I think this is probably too specialized a request to get in, especially since you want to have multiple parameter values and multiple x-values.
It's a feature available in rugarch package and it seems very useful for anyone working in finance. In rugarch it accepts a list of data frames, the list has the length equal to the number of external regressors. In python it could be a 3d numpy array.
I'm open to a PR but am unlikely to implement this myself.