[Scipy-svn] r3948 - trunk/scipy/stats/models

scipy-svn@scip... scipy-svn@scip...
Tue Feb 19 15:13:14 CST 2008


Author: jonathan.taylor
Date: 2008-02-19 15:13:12 -0600 (Tue, 19 Feb 2008)
New Revision: 3948

Modified:
   trunk/scipy/stats/models/contrast.py
Log:
clarifying doc string

Modified: trunk/scipy/stats/models/contrast.py
===================================================================
--- trunk/scipy/stats/models/contrast.py	2008-02-19 21:06:08 UTC (rev 3947)
+++ trunk/scipy/stats/models/contrast.py	2008-02-19 21:13:12 UTC (rev 3948)
@@ -98,9 +98,9 @@
             self.rank = 1
 
 
-def contrastfromcols(T, D, pseudo=None):
+def contrastfromcols(L, D, pseudo=None):
     """
-    From an n x p design matrix D and a matrix T, tries
+    From an n x p design matrix D and a matrix L, tries
     to determine a p x q contrast matrix C which
     determines a contrast of full rank, i.e. the
     n x q matrix
@@ -109,39 +109,46 @@
 
     is full rank.
 
-    T must satisfy either T.shape[0] == n or T.shape[1] == p.
+    L must satisfy either L.shape[0] == n or L.shape[1] == p.
 
+    If L.shape[0] == n, then L is thought of as representing
+    columns in the column space of D.
+
+    If L.shape[1] == p, then L is thought of as what is known
+    as a contrast matrix. In this case, this function returns an estimable
+    contrast corresponding to the dot(D, L.T)
+
     Note that this always produces a meaningful contrast, not always
     with the intended properties because q is always non-zero unless
-    T is identically 0. That is, it produces a contrast that spans
-    the column space of T (after projection onto the column space of D).
+    L is identically 0. That is, it produces a contrast that spans
+    the column space of L (after projection onto the column space of D).
 
     """
 
-    T = N.asarray(T)
+    L = N.asarray(L)
     D = N.asarray(D)
     
     n, p = D.shape
 
-    if T.shape[0] != n and T.shape[1] != p:
-        raise ValueError, 'shape of T and D mismatched'
+    if L.shape[0] != n and L.shape[1] != p:
+        raise ValueError, 'shape of L and D mismatched'
 
     if pseudo is None:
         pseudo = pinv(D)
 
-    if T.shape[0] == n:
-        C = N.dot(pseudo, T).T
+    if L.shape[0] == n:
+        C = N.dot(pseudo, L).T
     else:
-        C = T
+        C = L
         C = N.dot(pseudo, N.dot(D, C.T)).T
         
-    Tp = N.dot(D, C.T)
+    Lp = N.dot(D, C.T)
 
-    if len(Tp.shape) == 1:
-        Tp.shape = (n, 1)
+    if len(Lp.shape) == 1:
+        Lp.shape = (n, 1)
         
-    if utils.rank(Tp) != Tp.shape[1]:
-        Tp = utils.fullrank(Tp)
-        C = N.dot(pseudo, Tp).T
+    if utils.rank(Lp) != Lp.shape[1]:
+        Lp = utils.fullrank(Lp)
+        C = N.dot(pseudo, Lp).T
 
     return N.squeeze(C)



More information about the Scipy-svn mailing list