I am trying to conduct a two-way repeated measures ANOVA using the dataset below (df2):
# A tibble: 20 × 5
`Lateral Preference` Student `1st Grade` `2nd Grade` `3rd Grade`
<chr> <dbl> <dbl> <dbl> <dbl>
1 Left 1 22 26 34
2 Left 2 24 25 30
3 Left 3 18 22 24
4 Left 4 20 23 27
5 Left 5 30 36 40
6 Left 6 23 27 35
7 Left 7 23 24 29
8 Left 8 19 21 23
9 Left 9 29 24 28
10 Left 10 32 38 40
11 Right 11 27 29 34
12 Right 12 28 34 36
13 Right 13 25 26 28
14 Right 14 23 26 30
15 Right 15 26 34 36
16 Right 16 25 27 29
17 Right 17 30 31 35
18 Right 18 21 25 28
19 Right 19 24 25 28
20 Right 20 30 33 35
The following manipulations were performed to prep df2 for ANOVA:
df2 = df2 |>
pivot_longer(3:5, names_to = "GradeLevel", values_to = "ReadingScore") |>
rename(Handedness = `Lateral Preference`) |>
convert_as_factor(Handedness, Student, GradeLevel)
df2$GradeLevel = fct_inorder(df2$GradeLevel)
However, when I try to run the ANOVA within Handedness and GradeLevel
df2 |> anova_test(dv = ReadingScore,
wid = Student,
within = c(Handedness, GradeLevel))
I get the following error message:
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases
Everywhere I look says it is due to NAs in my data, but all(is.na(df2)) returns FALSE, so I don't know what is wrong.
I have tried reloading my packages in the order "rstatix, tidyverse" as has been suggested, and rearranged the data by GradeLevel, Student, or Handedness. There are no NA values in my data.
UPDATE: I found the root of my problem. I was getting an error because the factors in 'Handedness' did not apply to every student, so therefore the "within" parameter couldn't compare the students' reading score to the different handedness value. What I needed to do was a mixed-method ANOVA, shown below:
df2 |> anova_test(dv = ReadingScore,
wid = Student,
within = GradeLevel,
between = Handedness)