When I use anova_test()
function(from rstatix
package) to do two-way repeated measures ANOVA, an error occur:
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases
I check my data and there is no missing value.
BTW, in my data, not all the people have 8 times outcome
. Some people have maximum 3 times, some 8 times and so on.
I refer to this website to do my two-way repeated measures ANOVA :
https://www.datanovia.com/en/lessons/repeated-measures-anova-in-r/
I have upload my dataset to github.
mydata
:https://github.com/lizhiwei1994/testRepo/blob/master/mydata.csv
My code:
# load packages
library("tidyverse")
library("ggpubr")
library("rstatix")
# load data and check missing value
mydata <- read.csv(
url("https://raw.githubusercontent.com/lizhiwei1994/testRepo/master/mydata.csv")
) %>% convert_as_factor(id, time, treatment)
glimpse(mydata)
sum(is.na(mydata))
# error occurring
res.aov <- anova_test(
data = mydata, dv = outcome, wid = id,
within = c(treatment, time)
)
get_anova_table(res.aov)
aov(outcome ~ time*treatment + Error(id), data = mydata)
.