linearmodels.system.model.SUR¶
-
class linearmodels.system.model.SUR(equations: Mapping[str, Mapping[str, ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None] | Sequence[ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None]], *, sigma: ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None =
None)[source]¶ Seemingly unrelated regression estimation (SUR/SURE).
- Parameters:¶
- equations: Mapping[str, Mapping[str, ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None] | Sequence[ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None]]¶
Dictionary-like structure containing dependent and exogenous variable values. Each key is an equations label and must be a string. Each value must be either a tuple of the form (dependent, exog, [weights]) or a dictionary with keys “dependent” and “exog” and the optional key “weights”. The variables are array_like, such as lists, NumPy arrays, pandas objects and xarray DataArrays, and a
TypeErrorthat names the variable is raised for complex values or text.- sigma: ndarray | DataArray | DataFrame | Series | list[Any] | tuple[Any, ...] | None =
None¶ Prespecified residual covariance to use in GLS estimation, with shape (nequations, nequations). If not provided, FGLS is implemented based on an estimate of sigma.
Notes
Estimates a set of regressions which are seemingly unrelated in the sense that separate estimation would lead to consistent parameter estimates. Each equation is of the form
\[y_{i,k} = x_{i,k}\beta_i + \epsilon_{i,k}\]where k denotes the equation and i denoted the observation index. By stacking vertically arrays of dependent and placing the exogenous variables into a block diagonal array, the entire system can be compactly expressed as
\[Y = X\beta + \epsilon\]where
\[\begin{split}Y = \left[\begin{array}{c}Y_1 \\ Y_2 \\ \vdots \\ Y_K\end{array}\right]\end{split}\]and
\[\begin{split}X = \left[\begin{array}{cccc} X_1 & 0 & \ldots & 0 \\ 0 & X_2 & \dots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \dots & X_K \end{array}\right]\end{split}\]The system OLS estimator is
\[\hat{\beta}_{OLS} = (X'X)^{-1}X'Y\]When certain conditions are satisfied, a GLS estimator of the form
\[\hat{\beta}_{GLS} = (X'\Omega^{-1}X)^{-1}X'\Omega^{-1}Y\]can improve accuracy of coefficient estimates where
\[\Omega = \Sigma \otimes I_N\]where \(\Sigma\) is the covariance matrix of the residuals.
SUR is a special case of 3SLS where there are no endogenous regressors and no instruments.
The weights of an equation, if they are given, must be strictly positive and finite. They are rescaled to have a mean of 1 in the equation. A NaN weight is missing, and its observation is dropped from all of the equations.
Rows are paired by position, both within an equation and across the equations. An input that carries labels (a pandas Series or DataFrame with an index other than the default 0, 1, …, n-1, or an xarray DataArray with coordinates) must use the same index, in the same order, as the dependent variable of its equation, so that a value cannot be attached to the wrong observation. The dependent variables that carry labels must also use the same index in every equation. A
ValueErroris raised if an index differs. Either reindex the input to the index of the dependent variable, or callto_numpy()to pair its values by position. NumPy arrays and pandas objects with a default index do not carry labels and are always paired by position. If none of the dependent variables carries labels, the inputs that do must use the same index as the first of them that does, in the orderexog,endog,instrumentsandweightsof each equation. The same rule applies toclusterspassed tofit. Dates and time deltas are compared by value, so that the same dates at different resolutions, e.g.,datetime64[us]anddatetime64[ns], are the same labels.Methods
add_constraints(r[, q])Add parameter constraints to a model.
fit(*[, method, full_cov, iterate, ...])Estimate model parameters.
from_formula(formula, data, *[, sigma, weights])Specify a SUR using the formula interface.
multivariate_ls(dependent, exog)Interface for specification of multivariate regression models.
predict(params, *[, equations, data, eval_env])Predict values for additional data.
Remove all model constraints.
Properties
Model constraints.
Set or get the formula used to construct the model.
Vector indicating which equations contain constants.
Model parameter names.