[Scipy-svn] r2314 - trunk/Lib/sandbox/models

scipy-svn at scipy.org scipy-svn at scipy.org
Wed Nov 8 00:08:12 CST 2006


Author: timl
Date: 2006-11-08 00:07:57 -0600 (Wed, 08 Nov 2006)
New Revision: 2314

Modified:
   trunk/Lib/sandbox/models/regression.py
Log:
cleanup keyword args and fix class structure

Modified: trunk/Lib/sandbox/models/regression.py
===================================================================
--- trunk/Lib/sandbox/models/regression.py	2006-11-08 06:04:22 UTC (rev 2313)
+++ trunk/Lib/sandbox/models/regression.py	2006-11-08 06:07:57 UTC (rev 2314)
@@ -10,14 +10,14 @@
     A simple ordinary least squares model.
     """
 
-    def logL(self, b, Y, **extra):
+    def logL(self, b, Y):
         return -scipy.linalg.norm(self.whiten(Y) - N.dot(self.wdesign, b))**2 / 2.
 
-    def __init__(self, design, **keywords):
-        LikelihoodModel.__init__(self, **keywords)
+    def __init__(self, design):
+        LikelihoodModel.__init__(self)
         self.initialize(design)
 
-    def initialize(self, design, **keywords):
+    def initialize(self, design):
         self.design = design
         self.wdesign = self.whiten(design)
         self.calc_beta = L.pinv(self.wdesign)
@@ -41,7 +41,7 @@
         lfit.predict = N.dot(self.design, lfit.beta)
 
 
-    def fit(self, Y, **keywords):
+    def fit(self, Y):
         """
         Full \'fit\' of the model including estimate of covariance matrix, (whitened)
         residuals and scale. 
@@ -70,16 +70,16 @@
     determine the self.whiten method from AR(p) parameters.
     """
 
-    def __init__(self, design, rho=0, **keywords):
-        LikelihoodModel.__init__(self, **keywords)
+    def __init__(self, design, rho=0):
         self.rho = rho
-        self.initialize(design)
+        ols_model.__init__(self, design)
 
+
     def whiten(self, X):
         factor = 1. / N.sqrt(1 - self.rho**2)
         return N.concatenate([[X[0]], (X[1:] - self.rho * X[0:-1]) * factor])
 
-class wls_model(ar_model):
+class wls_model(ols_model):
     """
 
     A regression model with diagonal but non-identity covariance
@@ -88,11 +88,11 @@
 
     """
 
-    def __init__(self, design, weights=1, **keywords):
-        LikelihoodModel.__init__(self, **keywords)
+    def __init__(self, design, weights=1):
         self.weights = weights
-        self.initialize(design)
+        ols_model.__init__(self, design)
 
+
     def whiten(self, X):
         if X.ndim == 1:
             return X * N.sqrt(self.weights)
@@ -125,14 +125,13 @@
             raise ValueError, 'need normalized residuals to estimate standard deviation'
 
         sdd = utils.recipr(self.sd) / N.sqrt(self.df)
-        norm_resid = self.resid * N.multiply.outer(N.ones(self.Y.shape[0]), sdd)
-        return norm_resid
+        return  self.resid * N.multiply.outer(N.ones(self.Y.shape[0]), sdd)
 
+
     def predict(self, design):
         """
         Return fitted values from a design matrix.
         """
-
         return N.dot(design, self.beta)
 
     def Rsq(self, adjusted=False):



More information about the Scipy-svn mailing list