scikits.statsmodels.regression.WLS

class scikits.statsmodels.regression.WLS(endog, exog, weights=1.0)

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. Note that this is different than the behavior for GLS with a diagonal Sigma, where you would just supply W.

Methods

whiten
Returns the input scaled by sqrt(W)
Parameters:

endog : array-like

n length array containing the response variabl

exog : array-like

n x p array of design / exogenous data

weights : array-like, optional

1d array of weights. If you supply 1/W then the variables are pre- multiplied by 1/sqrt(W). If no weights are supplied the default value is 1 and WLS reults are the same as OLS.

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 scikits.statsmodels 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([ 0.0952381 ,  2.91666667])
>>> results.t()
array([ 0.35684428,  2.0652652 ])
<T test: effect=2.9166666666666674, sd=1.4122480109543243, t=2.0652651970780505, p=0.046901390323708769, df_denom=5>
>>> print results.f_test([1,0])
<F test: F=0.12733784321528099, p=0.735774089183, df_denom=5, df_num=1>

Attributes

weights array The stored weights supplied as an argument.
See regression.GLS    

Methods

fit() Full fit of the model.
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(exog[, params]) 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)

Previous topic

scikits.statsmodels.regression.GLS.whiten

Next topic

scikits.statsmodels.regression.WLS.fit

This Page