[R] Simple-Effects Test for Unbalanced Mixed ANOVA

Cory C cory@c@@c@lheir@ @ending from gm@il@com
Wed Dec 5 23:21:51 CET 2018


Hello everyone.

I am working on an Open Stats Lab (https://sites.trinity.edu/osl/) activity
for factorial ANOVA and have posted my analysis on GitHub (link below).

Once I have a significant interaction, how do I conduct a simple-effects
test in R?

The mixed design is unbalanced as follows:

1. within-subjects factor: Time 1, Time 2;
2. between-subjects factor: Condition 1 (ordinary; n = 64), Condition 2
(extraordinary; n = 66).

I imported the data and transformed it into long format.

    library(broom)
    library(car)
    library(nlme)
    library(tidyverse)

    > zhang_long[, 1:4]
    # A tibble: 260 x 4
       condition subject_id extra_time extra_rating
       <fct>     <fct>      <fct>             <dbl>
     1 ordinary  1          t1_extra              1
     2 ordinary  2          t1_extra              3
     3 ordinary  3          t1_extra              1
     4 ordinary  4          t1_extra              1
     5 ordinary  5          t1_extra              5
     6 ordinary  6          t1_extra              2
     7 ordinary  7          t1_extra              2
     8 ordinary  8          t1_extra              3
     9 ordinary  9          t1_extra              4
    10 ordinary  10         t1_extra              6
    # ... with 250 more rows

Since this is a practice activity, I can test my analyses against the
published paper. I was able to calculate the appropriate F-value using
car::Anova and nlme::lme.

    # Create linear mixed-effects model
    extra_lme <- lme(extra_rating ~ condition*extra_time, random =
~1|subject_id,
                     data = zhang_long)

    # Print ANOVA summary using type III sum of squares
    options(contrasts = c("contr.sum", "contr.poly"))
    Anova(extra_lme, type = "III")

But now I am stuck. How do I conduct a simple-effects test for the
interaction between time and condition?

I tried to subset the data by condition.

    # Split data by condition
    ordinary <- zhang_long %>% filter(condition == "ordinary")

    # Simple-effects test
    Anova(lme(extra_rating ~ extra_time, random = ~1|subject_id, data =
ordinary), type = "III")

This got me very close to the F-value reported in the paper, which is F(1,
128) = **39.86**.

    Analysis of Deviance Table (Type III tests)

    Response: extra_rating
                 Chisq Df Pr(>Chisq)
    (Intercept) 610.25  1  < 2.2e-16 ***
    extra_time   37.81  1  7.797e-10 ***
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

What am I doing wrong?

I uploaded a script and Rmarkdown document to GitHub:
https://github.com/corycaaz/osl-zhang-et-al-2014

Any help would be greatly appreciated!

Thank you,

Cory J. Cascalheira

	[[alternative HTML version deleted]]



More information about the R-help mailing list