requationlme4

Equatiomatic: lmer model "subsript out of bounds"


I am trying the equatiomatic package to plot my lmer model.

c1<-lmer(sqrt(co22)~t.air+t.soil+tdr+ph+TC+TN+wtd+Fe+0+(1|treatment/site), data=data)

However, when trying to extract the equation, I keep getting the error:

extract_eq(c1,wrap = TRUE, ital_vars = FALSE)

Error in `[<-`(`*tmp*`, v[1], v[2], value = greek_vcov) : 
  subscript out of bounds

But, it works fine if I convert the model to a simple linear model without random effects:

c1<-lm(sqrt(co22)~t.air+t.soil+tdr+ph+TC+TN+wtd+Fe+0, data=data)

extract_eq(c1,wrap = TRUE, ital_vars = FALSE)

$$
\begin{aligned}
\operatorname{sqrt(co22)} &= \beta_{0}(\operatorname{t.air}) + \beta_{1}(\operatorname{t.soil}) + \beta_{2}(\operatorname{tdr}) + \beta_{3}(\operatorname{ph})\ + \\
&\quad \beta_{4}(\operatorname{TC}) + \beta_{5}(\operatorname{TN}) + \beta_{6}(\operatorname{wtd}) + \beta_{7}(\operatorname{Fe})\ + \\
&\quad \epsilon
\end{aligned}
$$

Any suggestions on how to work-around the "subscript out of bounds"-error?


Solution

  • I'm the developer of that package. It should work with lme4::lmer() equations. The issue here is with dropping the intercept but having it vary randomly at higher levels. See this issue for more details.

    If you have suggestions for how you would expect the equation to render, I'm open to working out a fix. But for now, equatiomatic::extract_eq() assumes that whatever random effects you have also have corresponding fixed effects.