[R] simple main effect.
DrorD
dror.teach at gmail.com
Sat Feb 27 17:11:53 CET 2010
I tried to implement Ista's procedure and would like to provide it as
a working example, with the intention to get feedback from the R
community:
The data contains three variables:
One dependent var: t.total
and two independent vars: group (between: D2C2, C2D2) and present.type
(within: C2, D2).
# First I do the "overall" ANOVA:
m.full=aov(t.total ~ group * present.type + Error(subj/present.type),
data=dat.net)
summary(m.full)
Error: subj
Df Sum Sq Mean Sq F value Pr(>F)
group 1 1430 1430 0.4224 0.528
Residuals 12 40634 3386
Error: subj:present.type
Df Sum Sq Mean Sq F value Pr(>F)
present.type 1 603.1 603.1 0.7988 0.3890145
group:present.type 1 22775.8 22775.8 30.1661 0.0001379 ***
Residuals 12 9060.1 755.0
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 840 148493 177
-------------------------------
Now, since the interaction is significant, I want to compute two
simple main effects: to find out if there is a significant difference
between C2 and D2 (present.type var) (i) in group D2C2 and then also
(ii) in group C2D2 (won't be shown to avoid redundancy). To achieve
that:
(1) I run the model separately for each level of group:
dat.g1 = subset(dat.net, group=="D2C2")
m.g1 = aov(t.total ~ present.type + Error(subj/present.type),
data=dat.g1)
summary(m.g1)
Error: subj
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 6 22788 3798
Error: subj:present.type
Df Sum Sq Mean Sq F value Pr(>F)
present.type 1 15395.8 15395.8 18.694 0.004963 **
Residuals 6 4941.4 823.6
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 420 80658 192
-------------------------------
(2) I use the error term from the overall model (dat.net) to calculate
the MS-Error term:
MS-Effect(from model m.g1) for present.type = 15395.8 with df = 1
MS-Error(from model m.full) for present.type = 755.0 with df = 12
(from Error: subj:present.type)
so we have F(1,12) = 15395.8 / 755.0
which means F = 20.4 and to calculate p-sig:
1 - pf(20.4,1,12)
->> p=0.0007070375
Well, is this the way to do it?
Is it equivalent to or different from using the HH package?
Thanks in advance and best to all,
dror
----------------------
On Feb 27, 4:18 pm, Or Duek <ord... at gmail.com> wrote:
> I am very new to R and thus find those examples a bit confusing although I
> believe the solution to my problems lies there.
> Lets take for example an experiment in which I had two between subject
> variables - Strain and treatment, and one within - exposure. all the
> variables had 2 levels each.
>
> I found an interaction between exposure and Strain and I want to compare
> Strain A and B under every exposure (first and second).
> The general model was with that function:
> aov(duration~(Strain*exposure*treatment)+Error(subject/exposure),data)
>
> in summary(aovmodel) there was a significant interaction between exposure
> and strain.
> how (using those HH packages) can I compare Strains under the conditions of
> exposure?
>
> BTW - I don't have to use aov (although its seems to be the simplest one).
>
> Thank you very much.
>
> On Mon, Dec 21, 2009 at 12:16 AM, Richard M. Heiberger <r... at temple.edu>wrote:
>
>
>
>
>
> > For simple effects in the presence of interaction there are several
> > options included in the HH package. If you don't already have the HH
> > package, you can get it with
> > install.packages("HH")
>
> > Graphically, you can plot them with the function
> > interaction2wt(..., simple=TRUE)
> > See the examples in
> > ?HH::interaction2wt
>
> > For tests on the simple effect of A conditional on a level of B, you
> > can use the model formula B/A and look at the partition of the sums of
> > squares using the split= argument
> > summary(mymodel.aov, split=<put your details here>)
>
> > For multiple comparisons from designs with Error() terms, you need to
> > specify the same sums of squares with an equivalent formula that doesn't
> > use the Error() function. See the maiz example in
> > ?HH::MMC
> > Read the example all the way to the end of the help file.
>
> > Rich
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list