[Scipy-svn] r3948 - trunk/scipy/stats/models
Tue Feb 19 15:13:14 CST 2008
Date: 2008-02-19 15:13:12 -0600 (Tue, 19 Feb 2008)
New Revision: 3948
clarifying doc string
--- 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 == n or T.shape == p.
+ L must satisfy either L.shape == n or L.shape == p.
+ If L.shape == n, then L is thought of as representing
+ columns in the column space of D.
+ If L.shape == 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 != n and T.shape != p:
- raise ValueError, 'shape of T and D mismatched'
+ if L.shape != n and L.shape != p:
+ raise ValueError, 'shape of L and D mismatched'
if pseudo is None:
pseudo = pinv(D)
- if T.shape == n:
- C = N.dot(pseudo, T).T
+ if L.shape == n:
+ C = N.dot(pseudo, L).T
- 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:
- Tp = utils.fullrank(Tp)
- C = N.dot(pseudo, Tp).T
+ if utils.rank(Lp) != Lp.shape:
+ Lp = utils.fullrank(Lp)
+ C = N.dot(pseudo, Lp).T
More information about the Scipy-svn