Repeated measures ANOVA relies on listwise case deletion, dependent on the used variables. However, if there are missing values in variables not included in the analysis, these cases are currently omitted as well. Can this be changed?
library(tidyverse)
library(rstatix)
#>
#> Attache Paket: 'rstatix'
#> The following object is masked from 'package:stats':
#>
#> filter
library(datarium)
# Create an additional variable with values for each participant and 5 missing
additional <- 1:45
missing <- sample(additional, size = 5)
additional[missing] <- NA
# Add that as a new column to the "anxiety" dataset
anxiety_add <- anxiety %>% add_column(additional, .after = "id")
anxiety_long <- anxiety_add %>%
pivot_longer(
cols = t1:t3,
names_to = "time",
values_to = "score"
)
# Not that we don't use the column "additional"
anxiety_long %>%
anova_test(dv = score, wid = id, within = time, between = group)
#> Warning: NA detected in rows: 7,8,9,13,14,15,37,38,39,46,47,48,70,71,72.
#> Removing this rows before the analysis.
#> ANOVA Table (type III tests)
#>
#> $ANOVA
#> Effect DFn DFd F p p<.05 ges
#> 1 group 2 37 4.553 1.70e-02 * 0.193
#> 2 time 2 74 352.627 1.48e-38 * 0.195
#> 3 group:time 4 74 98.270 7.96e-29 * 0.119
#>
#> $`Mauchly's Test for Sphericity`
#> Effect W p p<.05
#> 1 time 0.888 0.117
#> 2 group:time 0.888 0.117
#>
#> $`Sphericity Corrections`
#> Effect GGe DF[GG] p[GG] p[GG]<.05 HFe DF[HF] p[HF]
#> 1 time 0.899 1.8, 66.53 6.42e-35 * 0.942 1.88, 69.72 1.80e-36
#> 2 group:time 0.899 3.6, 66.53 3.79e-26 * 0.942 3.77, 69.72 2.73e-27
#> p[HF]<.05
#> 1 *
#> 2 *
Repeated measures ANOVA relies on listwise case deletion, dependent on the used variables. However, if there are missing values in variables not included in the analysis, these cases are currently omitted as well. Can this be changed?
Created on 2020-03-27 by the reprex package (v0.3.0)