[R] se.contrast confusion

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Feb 14 08:39:46 CET 2007


On Tue, 13 Feb 2007, Adam D. I. Kramer wrote:

> Hello,
>
> I've got what I'd expect to be a pretty simple issue: I fit an aov object
> using multiple error strata, and would like some significance tests for the
> contrasts I specified.

It _is_ covered on the relevant help page.  See the 'split' argument in 
?summary.aov, and the examples there.

> In this contrived example, I model some test score as the interaction of a
> subject's gender and two emotion variables (angry, happy, neutral), measured
> at entry to the experiment (entry) and later manipulated (manip). This is a
> fully within-subjects design.
>
> Polynomial contrasts examine the effect of increasing emotional state
>
> levels(entry) and (manip) are "a" "n" "h", so I set
> contrasts(entry) <- contrasts(manip) <- contr.poly(3)
> (I am led to believe that this is equivalent to specifying
> contrasts=list(entry=contr.poly(3), manip=contr.poly(3)) in the aov call)
>
> ...and then fit the model:
>
> fit <- aov(score ~ gender*entry*manip + Error(subject/(entry*manip))
>
> ...at this point, summary(fit) tests all the main effects and interactions
> I'm interested in, and coef(fit) has the coefficients for all the contrasts
> and their interactions. The question, however, is how to test the
> significance of the contrasts, which is to say, compute the standard errors
> and apply them to coef(fit) in a meaningful way.
>
> The se.contrasts() function looks quite appealing, though it appears to

Do you mean se.contrast?  Or where did you find this function?

> require me to respecify the contrasts...in both a contrast.obj and a coef.
> It is not at all clear from the instrutions what contrast.obj is, especially
> given that I have already specified the contrasts and they are already
> represented in coef(fit). I may be missing something here.

You seem to be missing the ideas of 'optional' and 'default argument', 
as well as (I suspect) the correct name of the function.

You do need to specify _which_ contrasts you want, and these can be 
different from those in the fit (and often will not be all of those in the 
fit).  Looking at the examples would have made clear that 'coef' is 
optional.

> Could someone suggest a way to go from coef(fit) to a table like
> summary(fit) which tests the single-df contrasts (and interactions
> therebetween) which I specified? Or a way to compute the standard errors for
> these contrasts?


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list