Within an R session I would have the following formula:
members ~ face + class + gender + number + (day || country)
How would I write this in a math formula? By the way, is it a random slope random intercept model?
Within an R session I would have the following formula:
members ~ face + class + gender + number + (day || country)
How would I write this in a math formula? By the way, is it a random slope random intercept model?
tl;dr
This is just the "hard part"; your covariates that aren't involved in the random-effects part of the model would get added as part of the first equation (beta_2*face + beta_3*class + ...
). (By the way, it's unusual [i.e. probably wrong unless you have some specific reason for doing it this way], if days
is a continuous variable, to have it in the random-effects model and not in the fixed-effects model ...)
Using the development version of equatiomatic
(note that most of the complexity here is for turning the results of extract_eq()
into a PDF, then a PNG for posting here - requires some command-line tools (LaTeX, pdfcrop, ImageMagick). There may be a way to do this in a more self-contained way with the tinytex
package:
while (!require("equatiomatic")) {
remotes::install_github("datalorax/equatiomatic")
}
library(lme4)
m1 <- lmer(Reaction ~ Days + (Days||Subject), sleepstudy)
unlink("tmp.tex")
writeLines(c("\\documentclass{article}",
"\\usepackage{amsmath}",
"\\begin{document}",
"\\thispagestyle{empty}",
format(extract_eq(m1)),
"\\end{document}"),
con="tmp.tex")
system("pdflatex tmp.tex")
system("pdfcrop tmp.pdf")
system("convert tmp-crop.pdf tmp.png")