Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of missing values in anova_test() in mixed designs #31

Closed
benediktclaus opened this issue Mar 27, 2020 · 1 comment
Closed

Handling of missing values in anova_test() in mixed designs #31

benediktclaus opened this issue Mar 27, 2020 · 1 comment

Comments

@benediktclaus
Copy link

@benediktclaus benediktclaus commented Mar 27, 2020

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         *

Created on 2020-03-27 by the reprex package (v0.3.0)

@kassambara
Copy link
Owner

@kassambara kassambara commented Mar 29, 2020

Fixed now, thanks!

@kassambara kassambara closed this Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.