



Dear Seth,


Thanks again for your help. I've tried your suggestion with lmer(), and also aov(), lme(), ezANOVA() (see below). The results from aov(), lme(), and ezANOVA() are easier for me to interpret since I am used to p-values (and it looks like all three of them are giving the same result). However, as I understand from the discussions on the web there might be better statistical approaches than to rely on p-values … and I should rather use lmer()?

It is not clear to me though
1) How to interpret and report the output of lmer()? and
2) How do I check for normality and variance?


Thank you and best regards,
Marianne


######################################################################################################################


> #1) Run ANOVA -  lmer() from lme4 package
> anova_lme4_0 <- lmer(RT~Group+Session+(1|Subject)) # this model does not have an interaction effect
> anova_lme4_1 <- lmer(RT~Group*Session+(1|Subject)) # this model has an interaction effect.

> anova_lme4_0
Linear mixed model fit by REML 
Formula: RT ~ Group + Session + (1 | Subject) 
  AIC  BIC logLik deviance REMLdev
 1345 1359 -667.6     1356    1335
Random effects:
 Groups   Name        Variance Std.Dev.
 Subject  (Intercept) 7908.8   88.932  
 Residual             2985.8   54.643  
Number of obs: 120, groups: Subject, 21


Fixed effects:
            Estimate Std. Error t value
(Intercept)  442.286     58.013   7.624
Group         22.141     34.349   0.645
Session       -2.023      3.041  -0.665


Correlation of Fixed Effects:
        (Intr) Group 
Group   -0.930       
Session -0.121 -0.003

> anova_lme4_1
Linear mixed model fit by REML 
Formula: RT ~ Group * Session + (1 | Subject) 
  AIC  BIC logLik deviance REMLdev
 1342 1359   -665     1356    1330
Random effects:
 Groups   Name        Variance Std.Dev.
 Subject  (Intercept) 7889.3   88.822  
 Residual             3012.2   54.883  
Number of obs: 120, groups: Subject, 21


Fixed effects:
              Estimate Std. Error t value
(Intercept)    434.121     61.133   7.101
Group           27.316     36.462   0.749
Session          1.400      8.697   0.161
Group:Session   -2.163      5.149  -0.420


Correlation of Fixed Effects:
            (Intr) Group  Sessin
Group       -0.937              
Session     -0.338  0.316       
Group:Sessn  0.318 -0.338 -0.936
> 
> anova(anova_lme4_0, anova_lme4_1) #Compare these models with a likelihood ratio test
Data: 
Models:
anova_lme4_0: RT ~ Group + Session + (1 | Subject)
anova_lme4_1: RT ~ Group * Session + (1 | Subject)
             Df    AIC    BIC  logLik  Chisq Chi Df Pr(>Chisq)
anova_lme4_0  5 1366.0 1380.0 -678.02                         
anova_lme4_1  6 1367.8 1384.6 -677.92 0.1978      1     0.6565
> 
> #2) Run ANOVA - aov() from stats package
> anova_stats <-aov(RT~Group*Session+Error(Subject), data=table)
> summary(anova_stats)


Error: Subject
          Df Sum Sq Mean Sq F value Pr(>F)
Group      1  17784   17784   0.972  0.337
Residuals 18 329459   18303               


Error: Within
              Df Sum Sq Mean Sq F value Pr(>F)  
Session        1    831     831   0.408 0.5311  
Group:Session  1  10530   10530   5.166 0.0355 *
Residuals     18  36693    2038                 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
> 
> #3) Run ANOVA - lme() from nlme package
> anova_nlme <- lme(data=table, fixed=RT~Group*Session, random=~1|Subject)
> anova(anova_nlme)
              numDF denDF  F-value p-value
(Intercept)       1    18 516.7474  <.0001
Group             1    18   0.9716  0.3373
Session           1    18   0.4079  0.5311
Group:Session     1    18   5.1658  0.0355
> 
> 
> #4) Run ANOVA - ezANOVA() from ez package
> anova_ez <- ezANOVA(
+     data = table
+     , dv = RT
+     , wid = Subject
+     , within = Session
+     , between = Group
+     , detailed = TRUE
+ )
> 
> print(anova_ez)
$ANOVA
         Effect DFn DFd          SSn       SSd           F            p p<.05         ges
1   (Intercept)   1  18 9458174.4862 329459.44 516.7468877 1.044900e-14     * 0.962730059
2         Group   1  18   17784.0192 329459.44   0.9716290 3.373397e-01       0.046320259
3       Session   1  18     831.4249  36692.63   0.4078653 5.310979e-01       0.002265565
4 Group:Session   1  18   10530.4066  36692.63   5.1658145 3.552425e-02     * 0.027955658

> From: seth@swbigelow.net
> To: mariannestephan@hotmail.com; ;r-sig-mixed-models@r-project.org
> Subject: RE: [R-sig-ME] How do I check whether the assumptions of equal variances and normality are fulfilled for ezANOVA() ?
> Date: Fri, 9 Nov 2012 11:31:37 -0500
> 
> Marianne:
> 
> I'm not an R or statistics expert, but I've gotten a lot of good advice from
> those who are in this listserv, so I will attempt to pay it forward. (And I
> don't know anything about EZ anova).
> 
> What you've said about your data suggests that a mixed model might be a good
> way to analyze it. Group and Session would be fixed effects, and presumably
> there is subject, let's say a person, on whom a response measurement is
> taken at both sessions. Why start with a non-parametric model if you might
> be able to use a parametric one?
> 
> There are two packages commonly used for r mixed models: nlme (older) and
> lme4 (newer). Syntax for a simple analysis of your model in lme4 would look
> like
>  
> m0 <- lmer(response~Group+Session+(1|PersonsName))  # this model does not
> have an interaction effect
> m1 <- lmer(response~Group*Session+(1|PersonsName))  # this model has an
> interaction effect.
> 
> You can compare these models with a likelihood ratio test, e.g.
> Anova(m0,m1)
> It should give you a p value that will help to decide whether the
> interaction model is justified.
> Pinheiro & Bates (mixed effects models in S & S-Plus) is the standard mixed
> models reference, it is more oriented toward nlme but is very useful.
> 
> I, and others on this listserv no doubt, would be happy to provide advice
> re: residuals checking, if you decide to pursue the mixed models route.
> Sincerely, Seth W. Bigelow 
> 
> 
> 
> -----Original Message-----
> From: r-sig-mixed-models-bounces@r-project.org
> [mailto:r-sig-mixed-models-bounces@r-project.org] On Behalf Of Marianne K.
> Sent: Friday, November 09, 2012 8:40 AM
> To: r-sig-mixed-models@r-project.org
> Subject: [R-sig-ME] How do I check whether the assumptions of equal
> variances and normality are fulfilled for ezANOVA() ?
> 
> 
> Hello R and statistics experts,
> (Sorry for this probably basic question. I know there is a lot written about
> this topic, but it is still not clear to me.)
> 
> My data has one between-subject factor ("group", 2 levels, n=10 per group)
> and one within-subject factor ("session", 2 levels). I would like to use the
> ezANOVA function to test for main effects and interactions. 
> 
> 
> Now, how do I check whether the assumptions of equal variance and normality
> are fulfilled (which have to be fulfilled in order to use ezANOVA, right)?
> 
> 
> As I understood, Mauchlys test (which would give me an information about
> the equality of variances) is only calculated by ezANOVA if I have more than
> two within-subject levels.
> 
> 
> Do I have to check the normality of the residuals for each of the 4
> condition combinations with e.g. the following functions: qqnorm(mpg),
> qqline(mpg), shapiro.test(x)? How do I however get the residuals in order to
> do this? Then, should I use for example the Fligner-Killeen test for
> homogeneity of variances of all 4 condition combinations?
> 
[[elided Hotmail spam]]
> Thanks,Marianne 		 	   		  
> 	[[alternative HTML version deleted]]
> 
> 
 		 	   		  
 		 	   		  
	[[alternative HTML version deleted]]

