Ich analysiere meinen Datensatz (mit zwei Erhebungszeitpunkten, long-Format) mit "lmer" jeweils mit oder ohne Interaktionseffekt. Nun wollte ich meine Modelle mittels dem Befehl „anova“ vergleichen.
Code: Alles auswählen
M1_T <- lmer(formula = log(PSQI_globalindex) ~ Zeitpunkt_f + (1|Participant_ID), data = DATA_Long, REML = FALSE, na.action = na.omit)
summary(M1_T)
M2_T <- lmer(formula = log(PSQI_globalindex) ~ Zeitpunkt_f + Testosterone + (1|Participant_ID), data = DATA_Long, REML = FALSE, na.action = na.omit)
summary(M2_T)
##
anova(M1_T, M2_T)
Code: Alles auswählen
Error in anova.merMod(M1_T, M2_T) :
models were not all fitted to the same size of dataset
Code: Alles auswählen
# Recreating the dataset without NA
dataComplete <- get_all_vars(fit)[complete.cases(get_all_vars(fit)), ]
http://www.maths.bath.ac.uk/~jjf23/mixchange/repeated.html
# fit models
models <- c()
for (formula in combinations) {
newfit <- update(fit, formula, data = dataComplete)
models <- c(models, newfit)
}
Ganz liebe Grüsse und herzlichen Dank!