A regression model with diagonal but non-identity covariance structure.
The weights are presumed to be (proportional to) the inverse of the variance of the observations. That is, if the variables are to be transformed by 1/sqrt(W) you must supply weights = 1/W.
Parameters : | endog : array-like
exog : array-like
weights : array-like, optional
missing : str
|
---|
Notes
If the weights are a function of the data, then the postestimation statistics such as fvalue and mse_model might not be correct, as the package does not yet support no-constant regression.
Examples
>>> import numpy as np
>>> import statsmodels.api as sm
>>> Y = [1,3,4,5,2,3,4]
>>> X = range(1,8)
>>> X = sm.add_constant(X)
>>> wls_model = sm.WLS(Y,X, weights=range(1,8))
>>> results = wls_model.fit()
>>> results.params
array([ 2.91666667, 0.0952381 ])
>>> results.tvalues
array([ 2.0652652 , 0.35684428])
>>> print results.t_test([1, 0])
<T test: effect=array([ 2.91666667]), sd=array([[ 1.41224801]]), t=array([[ 2.0652652]]), p=array([[ 0.04690139]]), df_denom=5>
>>> print results.f_test([0, 1])
<F test: F=array([[ 0.12733784]]), p=[[ 0.73577409]], df_denom=5, df_num=1>
Attributes
weights | array | The stored weights supplied as an argument. |
See regression.GLS |
Methods
fit([method]) | Full fit of the model. |
from_formula(formula, data[, subset]) | Create a Model from a formula and dataframe. |
hessian(params) | The Hessian matrix of the model |
information(params) | Fisher information matrix of model |
initialize() | |
loglike(params) | Returns the value of the gaussian loglikelihood function at params. |
predict(params[, exog]) | Return linear predicted values from a design matrix. |
score(params) | Score vector of model. |
whiten(X) | Whitener for WLS model, multiplies each column by sqrt(self.weights) |
Attributes
endog_names | |
exog_names |