mojolearn.VAR#
- class mojolearn.VAR(endog, exog=None, numeric_mode=None)[source]#
Bases:
objectVector autoregression estimated by OLS.
Fits one least-squares regression per equation on the shared lagged design
[1, y[t-1], ..., y[t-p]], following statsmodels’VAR. The normal equations are solved in float32 by Cholesky, where statsmodels uses a float64 least-squares solve.- Parameters:
endog (array-like of shape (n_obs, n_variables)) – The multivariate series, float32. float64 raises TypeError.
exog (None) – Exogenous variables are not supported; anything other than None raises NotImplementedError.
numeric_mode (str or None, default None) – Numeric mode for this model (
'identical','deterministic'or'fast'); None uses the process default (seemojolearn.set_numeric_mode()).
Examples
>>> import numpy as np, mojolearn >>> y = np.random.default_rng(0).standard_normal((200, 3)).cumsum(axis=0).astype(np.float32) >>> res = mojolearn.VAR(y).fit(maxlags=2) >>> res.forecast(y, steps=5).shape (5, 3)
Methods
fit([maxlags, method, ic, trend])Estimate the VAR with a fixed lag order.
- fit(maxlags=1, method='ols', ic=None, trend='c')[source]#
Estimate the VAR with a fixed lag order.
- Parameters:
maxlags (int, default 1) – The lag order
p(used as is; there is no order selection).method ({“ols”}, default “ols”) – Estimation method.
ic (None) – Information-criterion order selection is not supported; anything other than None raises NotImplementedError.
trend ({“c”, “n”}, default “c”) –
"c"adds an intercept,"n"none."ct"and"ctt"raise NotImplementedError.
- Returns:
VARResults
- Raises:
numpy.linalg.LinAlgError – If the lagged design is rank deficient.