equatiomatic
equatiomatic copied to clipboard
NA introduced whenm using variable names with spaces in LME4 models
Consider the 4 models below. Only the 4th does not work and NA's instead of factor variables names are introduced when adding spaces to variable names (I am doing this to make the output more human friendly to read) in lme4 models, but not in OLS lm()
models.
library(lme4)
library(equatiomatic)
sim_longitudinal$`group dummy` <- as.factor(sim_longitudinal$group)
sim_longitudinal$group_dummy <- as.factor(sim_longitudinal$group)
## works
model1 <- lm(score ~ 1 + treatment + group_dummy,
data = sim_longitudinal)
extract_eq(model1)
## works
model2 <- lm(score ~ 1 + treatment + `group dummy`,
data = sim_longitudinal)
extract_eq(model2)
## works
model3 <- lmer(score ~ 1 + treatment + group_dummy + (1|school),
data = sim_longitudinal)
extract_eq(model3)
## does not work
model4 <- lmer(score ~ 1 + treatment + `group dummy` + (1|school),
data = sim_longitudinal)
extract_eq(model4)
Yeah this makes sense to me. We'll probably just need to build another wrapper for these. Thank you for the report!