Hello! I have a data set that was testing the effect of an intervention on disordered eating from pre-to-post test. There are 45 subjects. 24 subjects were randomized to condition 1. 21 subjects were randomized to condition 2, making this unbalanced.
Participants were asked to complete the same measure at two different time points.
The independent variables are condition and time (pre and post test). The condition is between-subjects and time is within-subjects. The dependent variable is the disordered eating score. There are also some missing values at follow-up. Ideally I would use maximum likelihood or multiple imputation to solve the missing values but I am going to use listwise deletion for now to keep things simple.
Below is the code I used, however, I've been reading a lot about ezANOVA and lme4. Would either of these approaches be more appropriate?
data<-read.spss("data", to.data.frame = TRUE)
head(data)
attach(data)
# Wide format
set.seed(123)
data("data")
data %>% sample_n_by(Condition, size = 1)
# Gather the columns into long format.
# Convert id and time into factor variables
data_long <- data %>%
gather(key = "time", value = "score", W1EatSum, W2EatSum) %>%
convert_as_factor(ID, time)
na_long<-na.omit(data_long)
# Inspect some random rows of the data by groups
set.seed(123)
na_long %>% sample_n_by(Condition, time, size = 1)
# Summary Statistics
na_long %>%
group_by(time, Condition) %>%
get_summary_stats(score, type = "mean_sd")
#Two-way mixed ANOVA test
res.aov <- anova_test(
data = na_long, dv = score, wid = ID,
between = Condition, within = time
)
get_anova_table(res.aov)
In terms of ezANOVA, I tried the following:
sdrc_mixed.model2<-ezANOVA(data=na_long, dv = .(score), wid = .(ID), within = .(time), between = .(Condition), type=3, detailed = T )
summary(sdrc_mixed.model2)
sdrc_mixed.model2
But after running it I recieved the following erroc/warnings
Warning: "Condition" will be treated as numeric.
Warning: Data is unbalanced (unequal N per group). Make sure you specified a well-considered value for the type argument to ezANOVA().
Error in ezANOVA_main(data = data, dv = dv, wid = wid, within = within, :
One or more cells is missing data. Try using ezDesign() to check your data.
Does anyone know how to fix the error from ezANOVA. Alternatively, is one of the methods (first, ezANOVA, or lme4) best in this situation?
Thank you!