arch icon indicating copy to clipboard operation
arch copied to clipboard

ENH: allow exogenous variable to be numpy 2-d array

Open lfdmotta opened this issue 3 years ago • 3 comments

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).

lfdmotta avatar Jul 29 '21 14:07 lfdmotta

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.

bashtage avatar Jul 30 '21 11:07 bashtage

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.

lfdmotta avatar Jul 30 '21 12:07 lfdmotta

I'm open to a PR but am unlikely to implement this myself.

bashtage avatar Jul 30 '21 16:07 bashtage