Generalized least squares model with a general covariance structure.
Parameters: | endog : array-like
exog : array-like
sigma : scalar or array
missing : str
hasconst : None or bool
**Attributes** : pinv_wexog : array
cholsimgainv : array
df_model : float
df_resid : float
llf : float
nobs : float
normalized_cov_params : array
results : RegressionResults instance
sigma : array
wexog : array
wendog : array
|
---|
Notes
If sigma is a function of the data making one of the regressors a constant, then the current postestimation statistics will not be correct.
Examples
>>> import numpy as np
>>> import statsmodels.api as sm
>>> data = sm.datasets.longley.load()
>>> data.exog = sm.add_constant(data.exog)
>>> ols_resid = sm.OLS(data.endog, data.exog).fit().resid
>>> res_fit = sm.OLS(ols_resid[1:], ols_resid[:-1]).fit()
>>> rho = res_fit.params
rho is a consistent estimator of the correlation of the residuals from an OLS fit of the longley data. It is assumed that this is the true rho of the AR process data.
>>> from scipy.linalg import toeplitz
>>> order = toeplitz(np.arange(16))
>>> sigma = rho**order
sigma is an n x n matrix of the autocorrelation structure of the data.
>>> gls_model = sm.GLS(data.endog, data.exog, sigma=sigma)
>>> gls_results = gls_model.fit()
>>> print(gls_results.summary())
Methods
fit([method, cov_type, cov_kwds, use_t]) | Full fit of the model. |
from_formula(formula, data[, subset, drop_cols]) | Create a Model from a formula and dataframe. |
get_distribution(params, scale[, exog, ...]) | Returns a random number generator for the predictive distribution. |
hessian(params) | The Hessian matrix of the model |
information(params) | Fisher information matrix of model |
initialize() | |
loglike(params) | Returns the value of the Gaussian log-likelihood function at params. |
predict(params[, exog]) | Return linear predicted values from a design matrix. |
score(params) | Score vector of model. |
whiten(X) | GLS whiten method. |
Methods
fit([method, cov_type, cov_kwds, use_t]) | Full fit of the model. |
from_formula(formula, data[, subset, drop_cols]) | Create a Model from a formula and dataframe. |
get_distribution(params, scale[, exog, ...]) | Returns a random number generator for the predictive distribution. |
hessian(params) | The Hessian matrix of the model |
information(params) | Fisher information matrix of model |
initialize() | |
loglike(params) | Returns the value of the Gaussian log-likelihood function at params. |
predict(params[, exog]) | Return linear predicted values from a design matrix. |
score(params) | Score vector of model. |
whiten(X) | GLS whiten method. |
Attributes
df_model | The model degree of freedom, defined as the rank of the regressor matrix minus 1 if a constant is included. |
df_resid | The residual degree of freedom, defined as the number of observations minus the rank of the regressor matrix. |
endog_names | Names of endogenous variables |
exog_names | Names of exogenous variables |