Skip to content

Commit

Permalink
Fixed duplicate svd in RegressionModel
Browse files Browse the repository at this point in the history
  • Loading branch information
guyrt committed Sep 24, 2013
1 parent 16365ed commit 12a4694
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions statsmodels/regression/linear_model.py
Expand Up @@ -80,15 +80,13 @@ def __init__(self, endog, exog, **kwargs):
self._data_attr.extend(['pinv_wexog', 'wendog', 'wexog', 'weights'])

def initialize(self):
#print "calling initialize, now whitening" #for debugging
self.wexog = self.whiten(self.exog)
self.wendog = self.whiten(self.endog)
# overwrite nobs from class Model:
self.nobs = float(self.wexog.shape[0])
self.rank = rank(self.exog)
self.df_model = float(self.rank - self.k_constant)
self.df_resid = self.nobs - self.rank
self.df_model = float(rank(self.exog) - self.k_constant)

def fit(self, method="pinv", **kwargs):
"""
Expand Down Expand Up @@ -124,9 +122,10 @@ def fit(self, method="pinv", **kwargs):
if ((not hasattr(self, 'pinv_wexog')) or
(not hasattr(self, 'normalized_cov_params'))):
#print "recalculating pinv" #for debugging
self.pinv_wexog = pinv_wexog = np.linalg.pinv(self.wexog)
self.normalized_cov_params = np.dot(pinv_wexog,
np.transpose(pinv_wexog))
self.pinv_wexog = np.linalg.pinv(self.wexog)
self.normalized_cov_params = np.dot(self.pinv_wexog,
np.transpose(self.pinv_wexog))

beta = np.dot(self.pinv_wexog, endog)

elif method == "qr":
Expand Down

0 comments on commit 12a4694

Please sign in to comment.