How to compute simple effects

893 views
Skip to first unread message

or duek

unread,
Oct 10, 2011, 4:26:16 PM10/10/11
to ez4r
Hi,
First of all, I just found out about this great package, thank you
very much.
I have two questions:
1. Do you made some equivalent package to help us use regression and/
or GLMs?

2. If I want to check for a simple effect (after I saw the interaction
was significant) in a mixed design, using ezANOVA (two between and one
within variable) - how can I do it?

Thank you very much.
O.

Thom

unread,
Oct 11, 2011, 5:58:30 AM10/11/11
to ez4r

Here is an old blog entry of mine on how to do this from generic
software output (including potentially R).

http://psychologicalstatistics.blogspot.com/2006/07/how-to-calculate-simple-main-effects.html

However, I would caution about using simple main effects to follow-up
an interaction (and I have somewhat changed my view of their utility
since I wrote that entry). They aren't really interaction follow-ups.
The simple main effects decompose Sums of Squares attributed to the
interaction and to one of the main effects. So if you have a
hypothesis about an interaction, simple main effects may simply be a
way of testing that hypothesis that decreases power (e.g., by reducing
n or carving the interaction in 'smaller' effects that are harder to
detect). If the interaction has 1 treatment df (e.g., 2 x 2 ANOVA)
then it is a focused test that can't be decomposed further. If the
interaction has multiple treatment df then it can be decomposed
further - but the correct method is an interaction contrast (not
simple main effects).

Simple main effects may be useful if they reflect the hypothesis of
interest.

Thom

or duek

unread,
Oct 11, 2011, 6:05:55 AM10/11/11
to ez4r
Thank you very much for your reply.
Is it possible to use interaction contrasts with ezANOVA?

On Oct 11, 11:58 am, Thom <thomas.bagu...@ntu.ac.uk> wrote:
> Here is an old blog entry of mine on how to do this from generic
> software output (including potentially R).
>
> http://psychologicalstatistics.blogspot.com/2006/07/how-to-calculate-...

Thom

unread,
Oct 11, 2011, 9:18:39 AM10/11/11
to ez4r

I'm not sure what contrasts are available in ezANOVA. Though an
ezContrast() function would be a nice project.

I cover interaction contrasts in my forthcoming book and have examples
of running them in R via the gmodels package or via the multcomp
package. The tricky bit with contrasts is selecting the contrast
weights and getting a suitable error term out of your software.

Thom

or duek

unread,
Oct 16, 2011, 6:31:04 AM10/16/11
to ez4r
Well, compared to Statistica and SPSS it is really hard to run those
analyses.
I actually am going to those software in order to easily do that.
It is a shame, usually when you analyse data you need to understand
the interaction and we can't do it without easy comparison function.
I think it would be GREAT to add ezContrasts to this package.
I know I would be thrilled.
It can be same as SPSS's Emmeans.
Thank you for your replies.
I will probably wait for your book to understand how to do it in R.

Thom

unread,
Oct 16, 2011, 3:00:25 PM10/16/11
to ez4r

It depends on design. The simple main effects for within subjects/
repeated
measures factors are just one-way ANOVAs on the subset of the data you
are
interested in. For between subject factors just get the MSe from the
original
ANOVA and then you can compute in R from a vector of cell means in a
balanced design. so something like this should work:

ms.error <- 10
cell.means <- c(14, 16, 22, 23)
n <- 10

ss.sme <- n * var(cell.means)
df.sme <- length(cell.means) - 1
ms.sme <- ss.sme / df.sme
F.sme <- ms.sme / ms.error
F.sme
pf(F.sme, df.sme, df.error, lower.tail=FALSE)

For a between-subject factor in a mixed design you need to pool two
error terms and it is fiddly, though there is an excel spreadsheet on
my
blog that does this. For some reason I never implemented this in R
but it is a simple matter of pooling the variances and using a
Welch-Satterthwaite style correction for the df.

For contrasts, you can run them fairly easily in the gmodels or
multcomp
packages. The gmodels packages is more versatile (e.g., working with
mer and lme objects) while multcomp has options for multiple
comparison
prodecures that are more powerful than those in SPSS or Statistica. In
fact,
SPSS contrasts are extremely hard to set up for anything other than
contrasts on a single factor.

Thom

or duek

unread,
Oct 17, 2011, 9:12:13 AM10/17/11
to ez4r
thank you.
I took your advice and did the following:
I have one within subject variable and two between. I wanted to check
for simple simple main effect under one level of the within subject.
So first I subsetted the data to include just that level (with the
full two other variables)
I then ran aov function on this, subsetted data.
then I computed SSBatA1 from scratch because I have unbalanced design.
It went something like:
SSBatA1<-sum(n1*A*(meanb1a1-meanba1)^2+n2*A(meanb2a1-meanba1)^2)
because there are only 2 the df=1.
I then computed the F as you showed, using the MSE from the aov
function.
Is it correct?

Thank you very much.
Or.

Thom

unread,
Oct 18, 2011, 5:44:41 AM10/18/11
to ez4r

I think so.

If you have say gender (M, F) and a within factor such as condition
then
to find the gender difference at that each condition you'd do as you
suggest.

The point of the MSerror from the original ANOVA is just to get a more
accurate pooled error. This assume homogeneity of variance so a t test
with a Welch-Satterthwaite correction (the default in R) would be
reasonable if that was untenable. Of course logic says that if you
were
happy with the pooled error term in your main analysis you should
stick
with it.

Repeated measures routinely uses a non-pooled error term to avoid
sphericity
issues.

Thom
Reply all
Reply to author
Forward
0 new messages