All 1 entries tagged Contrasts

No other Warwick Blogs use the tag Contrasts on entries | View entries tagged Contrasts at Technorati | There are no images tagged Contrasts on this blog

November 10, 2010

Orthogonal polynomials with intuitive scale

When creating regressors (or contrasts) for a parametric experimental design, it is often useful to model (or test) linear, quadratic and cubic effects separately. However, if you just use the usual x, x*x, x*x*x approach to create predictors, you wil create highly correlated variables. Specifically, the quadratic term will include some of the linear effect, and vice-versa. The solution is to use orthogonal polynomials.

The very simplest way to do this is with Matlab’s orth function. E.g. for 10-level parametric regressor
n=10;
x=[1:n]';
One=ones(n,1);
X0=[One x x.^2 x.^3];
X=orth(X0);
plot(X)

But annoyingly, this standardizes the columns and produces a fairly uninterprtable basis. In particular, while a linear trend can be represented by a linear combination of those columns, it is not in any one single column.

Instead, we can carefully build up a basis that is mean zero, and uses successive othogonalization to ensure the interpretability of each column.
n=10;
x=[1:n]';
One=ones(n,1);
X0=[x x.^2 x.^3];
X=One;
for i=1:size(X0,2)
  X=[X X0(:,i)-X*pinv(X)*X0(:,i)];
end
plot(X)

Now we have three columns readily identifiable as intercept, linear, quadratic and cubic terms; after the first column, they are mean zero (so that they do not carry any of the grand mean), and all are orthogonal, as can be checked with corrcoef(X).

There are of course specialized functions to create orthogonal polynomials, but for this purpose, this code snippet is all you need.


Search this blog

Tags

Most recent comments

  • I love this quote: "Complete reporting of results, i.e. filing of statistical maps in public reposit… by Kevin Black on this entry
  • Taylor: I've just quickly scanned the BrainVoyager documentation, and it appears that the Cluster–Le… by Thomas Nichols on this entry
  • Cindy, I can see you didn't like my comments but I didn't get based on what you deemed them outrageo… by Yolanda on this entry
  • Thomas, Could you comment on the applicability of your findings to BrainVoyager's Cluster–Level Stat… by Taylor on this entry
  • Here is a sample of recent corrections from PNAS, collated by Mike Angstadt. Correction for Crockett… by Thomas Nichols on this entry

Blog archive

Loading…
RSS2.0 Atom
Not signed in
Sign in

Powered by BlogBuilder
© MMXXI