### Navigation

- index
- modules |
- next |
- previous |
- statsmodels v0.2.0 documentation »
- Regression »

# scikits.statsmodels.regression.GLS

class `scikits.statsmodels.regression.``GLS`(endog, exog, sigma=None)

  Generalized least squares model with a general covariance structure.

  Parameters: | endog : array-like endog is a 1-d vector that contains the response/independent variable exog : array-like exog is a n x p vector where n is the number of observations and p is the number of regressors/dependent variables including the intercept if one is included in the data. sigma : scalar or array sigma is the weighting matrix of the covariance. The default is None for no scaling. If sigma is a scalar, it is assumed that sigma is an n x n diagonal matrix with the given scalar, sigma as the value of each diagonal element. If sigma is an n-length vector, then sigma is assumed to be a diagonal matrix with the given sigma on the diagonal. This should be the same as WLS.

  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 scikits.statsmodels 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.results

  Attributes

  pinv_wexog | array | pinv_wexog is the p x n Moore-Penrose pseudoinverse of wexog.
  cholsimgainv | array | The transpose of the Cholesky decomposition of the pseudoinverse.
  df_model | float | p - 1, where p is the number of regressors including the intercept. of freedom.
  df_resid | float | Number of observations n less the number of parameters p.
  llf | float | The value of the likelihood function of the fitted model.
  nobs | float | The number of observations n.
  normalized_cov_params | array | p x p array
  sigma | array | sigma is the n x n covariance structure of the error terms.
  wexog | array | Design matrix whitened by cholsigmainv
  wendog | array | Response variable whitened by cholsigmainv

  Methods

  `fit`() | Full fit of the model.
  `information`(params) | Fisher information matrix of model
  `initialize`() |
  `loglike`(params) | Returns the value of the gaussian loglikelihood function at params.
  `predict`(exog[, params]) | Return linear predicted values from a design matrix.
  `score`(params) | Score vector of model.
  `whiten`(X) | GLS whiten method.

  newton | Used to solve the maximum likelihood problem.

### Navigation

- index
- modules |
- next |
- previous |
- statsmodels v0.2.0 documentation »
- Regression »