Skip to content

Commit

Permalink
Merge c6d82f8 into 4f675c7
Browse files Browse the repository at this point in the history
  • Loading branch information
guyrt committed Nov 2, 2013
2 parents 4f675c7 + c6d82f8 commit 534b14f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 12 deletions.
6 changes: 3 additions & 3 deletions docs/source/release/version0.6.rst
Expand Up @@ -20,7 +20,7 @@ Other important new features
----------------------------

* Other new changes can go
* In a
* In a
* Bullet list

Major Bugs fixed
Expand All @@ -33,14 +33,14 @@ Major Bugs fixed
Backwards incompatible changes and deprecations
-----------------------------------------------

* Note any backwards incompatible changes here
* RegressionResults.norm_resid is now a readonly property, rather than a function.

Development summary and credits
-------------------------------

A blurb about the number of changes and the contributors list.

.. note::
.. note::

Obtained by running ``git log v0.5.0..HEAD --format='* %aN <%aE>' | sed 's/@/\-at\-/' | sed 's/<>//' | sort -u``.

17 changes: 8 additions & 9 deletions statsmodels/regression/linear_model.py
Expand Up @@ -114,6 +114,9 @@ def df_resid(self):
def df_resid(self, value):
self._df_resid = value

def whiten(self, X):
raise NotImplementedError("Subclasses should implement.")

def fit(self, method="pinv", **kwargs):
"""
Full fit of the model.
Expand Down Expand Up @@ -1122,18 +1125,14 @@ def HC3_se(self):
self._HC3_se = np.sqrt(np.diag(self.cov_HC3))
return self._HC3_se

#TODO: this needs a test
@cache_readonly
def norm_resid(self):
"""
Residuals, normalized to have unit length and unit variance.
Returns
-------
An array wresid/sqrt(scale)
Notes
-----
This method is untested
"""
if not hasattr(self, 'resid'):
raise ValueError('need normalized residuals to estimate standard '
Expand Down Expand Up @@ -1691,19 +1690,19 @@ class RegressionResultsWrapper(wrap.ResultsWrapper):
'HC0_se' : 'columns',
'HC1_se' : 'columns',
'HC2_se' : 'columns',
'HC3_se' : 'columns'
'HC3_se' : 'columns',
'norm_resid' : 'rows',
}

_wrap_attrs = wrap.union_dicts(base.LikelihoodResultsWrapper._attrs,
_attrs)

_methods = {
'norm_resid' : 'rows',
}
_methods = {}

_wrap_methods = wrap.union_dicts(
base.LikelihoodResultsWrapper._wrap_methods,
_methods)

wrap.populate_wrapper(RegressionResultsWrapper,
RegressionResults)

Expand Down
29 changes: 29 additions & 0 deletions statsmodels/regression/tests/results/results_regression.py
Expand Up @@ -43,6 +43,14 @@ def __init__(self):
-17.26893, -39.05504, -155.54997, -85.67131, 341.93151,
-206.75783))

# Obtained from R using m$residuals / sqrt(sum(m$residuals * m$residuals) / m$df.residual)
self.norm_resid = np.array((0.87694426, -0.30838998,
0.15183385, -1.34528175, 1.01594375,
-0.81780510, -0.53812289, -0.04323497,
0.04692334, 1.49381010, -0.05664654,
-0.12811061, -0.51024404, -0.28102399,
1.12162357, -0.67821900))

def conf_int(self): # a method to be consistent with sm
return [(-177.0291,207.1524), (-.111581,.0399428),(-3.125065,
-.9153928),(-1.517948,-.5485049),(-.5625173,.4603083),
Expand Down Expand Up @@ -130,6 +138,20 @@ def __init__(self):
-100.632293701, 34.9342498779, -96.6685943604,
-367.32925415, -40.1300048828, -72.8692245483,
-60.8728256226, -35.9937324524, -222.944747925]
self.norm_resid = \
[-0.90569581, -0.75496938, -1.28663890, -0.11309411, -0.24746253, -0.47181831,
-1.02062293, -0.31403683, 1.62862142, -0.84973225, -0.42919669, -0.78007426,
-0.63913772, 0.29787637, -0.38364568, -0.21381846, -0.85577361, 0.54156452,
-0.48496031, -1.15374603, 0.41145856, 0.23996158, 2.70305838, -0.53171027,
0.79057028, 1.82433320, -0.04150362, 0.97048328, 0.13667658, 0.26750667,
-0.12690810, 0.11703354, -0.72689772, 0.34160874, 0.71332338, -0.75079661,
1.73137185, -0.39477348, 0.04107215, -0.11332274, 0.22952063, -0.88580496,
-0.67239515, -0.17656300, 4.48867723, 2.61499898, -0.16988320, -0.63136893,
-0.68135396, 0.06351572, -0.64467367, -0.37800911, -0.64304809, 1.88607184,
0.57624742, 0.60875207, -0.78636761, -0.17897383, -0.21716827, -0.07885570,
-0.57566752, 0.25202879, -0.29176531, -0.54378274, 0.30203654, -0.57460072,
-0.72378394, -0.23853382, -0.17325464, -0.24121979, -0.10269489, -0.57826451]


def conf_int(self): # a method to be consistent with sm
return [( -10.2936, 4.90523), ( 5.949595, 310.9044),
Expand Down Expand Up @@ -165,6 +187,13 @@ def __init__(self):
201.321121216, 215.908889771, 73.0936813354, 913.216918945,
424.824859619, -8.56475830078, -361.329742432,
27.3456058502, 151.28956604, -492.499359131]
# Obtained from R using m$residuals / sqrt(sum(m$residuals * m$residuals) / m$df.residual)
self.norm_resid = [0.58906369, -0.27427213, 0.19094881,
-0.84457419, -0.92697740, -1.14390695,
0.42368630, 0.45438671, 0.15382784,
1.92189233, 0.89405658, -0.01802479,
-0.76042924, 0.05754964, 0.31839340,
-1.03647964]

def conf_int(self):
return [(-341.6373, 235.6502), ( .0038583, .1382881),
Expand Down
5 changes: 5 additions & 0 deletions statsmodels/regression/tests/test_regression.py
Expand Up @@ -135,6 +135,11 @@ def test_resids(self):
assert_almost_equal(self.res1.resid, self.res2.resid,
self.decimal_resids)

decimal_norm_resids = DECIMAL_4
def test_norm_resids(self):
assert_almost_equal(self.res1.norm_resid, self.res2.norm_resid,
self.decimal_norm_resids)

#TODO: test fittedvalues and what else?

class TestOLS(CheckRegressionResults):
Expand Down

0 comments on commit 534b14f

Please sign in to comment.