#### Previous topic

Financial models package

#### Next topic

Neural network models module

# Econometric models module¶

Some econometric models.

 fynance.models.econometric_models.MA(y, …) Moving Average model of order q s.t: fynance.models.econometric_models.ARMA(y, …) AutoRegressive Moving Average model of order q and p s.t: fynance.models.econometric_models.ARMA_GARCH(y, …) AutoRegressive Moving Average model of order q and p, such that: fynance.models.econometric_models.ARMAX_GARCH(y, …) AutoRegressive Moving Average model of order q and p, such that:

## Time series models¶

fynance.models.econometric_models.MA(y, theta, c, q)

Moving Average model of order q s.t:

$y_t = c + \theta_1 * u_{t-1} + ... + \theta_q * u_{t-q} + u_t$
Parameters: y : np.ndarray[np.float64, ndim=1] Time series. theta : np.ndarray[np.float64, ndim=1] Coefficients of model. c : np.float64 Constant of the model. q : int Order of MA(q) model. u : np.ndarray[ndim=1, dtype=np.float64] Residual of the model.

Examples

>>> y = np.array([3, 4, 6, 8, 5, 3])
>>> MA(y=y, theta=np.array([0.8]), c=3, q=1)
array([ 0.    ,  1.    ,  2.2   ,  3.24  , -0.592 ,  0.4736])

fynance.models.econometric_models.ARMA(y, phi, theta, c, p, q)

AutoRegressive Moving Average model of order q and p s.t:

$y_t = c + \phi_1 * y_{t-1} + ... + \phi_p * y_{t-p} + \theta_1 * u_{t-1} + ... + \theta_q * u_{t-q} + u_t$
Parameters: y : np.ndarray[np.float64, ndim=1] Time series. phi : np.ndarray[np.float64, ndim=1] Coefficients of AR model. theta : np.ndarray[np.float64, ndim=1] Coefficients of MA model. c : np.float64 Constant of the model. p : int Order of AR(p) model. q : int Order of MA(q) model. u : np.ndarray[np.float64, ndim=1] Residual of the model.
fynance.models.econometric_models.ARMA_GARCH(y, phi, theta, alpha, beta, c, omega, p, q, Q, P)

AutoRegressive Moving Average model of order q and p, such that:

$y_t = c + \phi_1 * y_{t-1} + ... + \phi_p * y_{t-p} + \theta_1 * u_{t-1} + ... + \theta_q * u_{t-q} + u_t$

With Generalized AutoRegressive Conditional Heteroskedasticity volatility model of order Q and P, such that:

\begin{align}\begin{aligned}u_t = z_t * h_t\\h_t^2 = \omega + \alpha_1 * u^2_{t-1} + ... + \alpha_Q * u^2_{t-Q} + \beta_1 * h^2_{t-1} + ... + \beta_P * h^2_{t-P}\end{aligned}\end{align}
Parameters: y : np.ndarray[np.float64, ndim=1] Time series. phi : np.ndarray[np.float64, ndim=1] Coefficients of AR model. theta : np.ndarray[np.float64, ndim=1] Coefficients of MA model. alpha : np.ndarray[np.float64, ndim=1] Coefficients of MA part of GARCH. beta : np.ndarray[np.float64, ndim=1] Coefficients of AR part of GARCH. c : np.float64 Constant of ARMA model. omega : np.float64 Constant of GARCH model. p : int Order of AR(p) model. q : int Order of MA(q) model. Q : int Order of MA part of GARCH. P : int Order of AR part of GARCH. u : np.ndarray[np.float64, ndim=1] Residual of the model. h : np.ndarray[np.float64, ndim=1] Conditional volatility of the model.

ARMAX_GARCH, ARMA, MA.
fynance.models.econometric_models.ARMAX_GARCH(y, x, phi, psi, theta, alpha, beta, c, omega, p, q, Q, P)

AutoRegressive Moving Average model of order q and p, such that:

$y_t = c + \phi_1 * y_{t-1} + ... + \phi_p * y_{t-p} + \psi_t * x_t + \theta_1 * u_{t-1} + ... + \theta_q * u_{t-q} + u_t$

With Generalized AutoRegressive Conditional Heteroskedasticity volatility model of order Q and P, such that:

\begin{align}\begin{aligned}u_t = z_t * h_t\\h_t^2 = \omega + \alpha_1 * u^2_{t-1} + ... + \alpha_Q * u^2_{t-Q} + \beta_1 * h^2_{t-1} + ... + \beta_P * h^2_{t-P}\end{aligned}\end{align}
Parameters: y : np.ndarray[np.float64, ndim=1] Time series. x : np.ndarray[np.float64, ndim=2] Time series of external features. phi : np.ndarray[np.float64, ndim=1] Coefficients of AR model. psi : np.ndarray[np.float64, ndim=1] Coefficients of external features. theta : np.ndarray[np.float64, ndim=1] Coefficients of MA model. alpha : np.ndarray[np.float64, ndim=1] Coefficients of MA part of GARCH. beta : np.ndarray[np.float64, ndim=1] Coefficients of AR part of GARCH. c : np.float64 Constant of the model. p : int Order of AR(p) model. q : int Order of MA(q) model. Q : int Order of MA part of GARCH. P : int Order of AR part of GARCH. u : np.ndarray[np.float64, ndim=1] Residual of the model. h : np.ndarray[np.float64, ndim=1] Conditional volatility of the model.

ARMA_GARCH, ARMA, MA.
fynance.models.econometric_models.get_parameters(params, p=0, q=0, Q=0, P=0, cons=True)