Skip to content

Error fitting reduced model in bglmer for LRT

2 messages · Josie Galbraith, Vincent Dorie

#
Hi all,

In following on from this post
<https://stat.ethz.ch/pipermail/r-sig-mixed-models/2015q1/023191.html>,
regarding using blme and fixed effect priors to address issues of complete
separation in my data, I've come up against a problem trying to fit reduced
models for testing the model terms using likelihood ratio tests (LRT).

Firstly, can I use LRTs (anova()) for testing the fixed effects of bglmer
models, as I would for glmer models?

If yes, then I need help understanding why I'm getting the following error
fitting a reduced bglmer model:
"Error in if (nrow(cov) == 2) { : argument is of length zero"

This is my full model:
SE.les.mod = bglmer (LESION ~ FOOD*SEASON +(1|SITE), data = SEYE.df, family
= binomial, fixef.prior = t(1,2.5), cov.prior = NULL)

I can fit a model without the interaction term ok:
SE.les.add = bglmer (LESION ~ FOOD+SEASON +(1|SITE), data = SEYE.df, family
= binomial, fixef.prior = t(1,2.5), cov.prior = NULL)

But I get the error message with both of the single fixed effects models:
SE.les.FOOD = bglmer (LESION ~ SEASON +(1|SITE), data = SEYE.df, family =
binomial, fixef.prior = t(1,2.5), cov.prior = NULL)
SE.les.SEAS = bglmer (LESION ~ FOOD +(1|SITE), data = SEYE.df, family =
binomial, fixef.prior = t(1,2.5), cov.prior = NULL)

Thanks very much,
Josie
#
I don't know what exactly anova() does for glmms, but I wouldn't recommend a likelihood ratio test to compare posterior modes unless you can be certain the data swamp the prior.

The error you experienced is a copy/paste error on my part. You can run the code below to fix it temporarily, until I can get a new release on CRAN.

assignInNamespace("toString.bmerTDist", function(x, digits = getOption("digits"), ...) {
  scaleString <- ""
  scale <- crossprod(solve(x at R.scale.inv))
  
  if (nrow(scale) > 2) {
    scaleString <- paste("scale = c(", toString(round(scale[1:4], digits)), ", ...)", sep = "")
  } else if (nrow(scale) == 2) {
    scaleString <- paste("scale = c(", toString(round(scale[1:4], digits)), ")", sep = "")
  } else {
    scaleString <- paste("scale = ", toString(round(scale[1], digits)), sep = "")
  }
  
  paste("t(df = ", x at df, ", ", scaleString,
        ", common.scale = ", x at commonScale,
        ")", sep="")
}, "blme")

Vince