glmer.mp: Multinomial-Poisson GLMM for nominal response data

View source: R/glmer.mp.R

glmer.mpR Documentation

Multinomial-Poisson GLMM for nominal response data

Description

This function uses the multinomial-Poisson trick to analyze nominal response data using a Poisson generalized linear mixed model (GLMM). The nominal response should be a factor with two or more unordered categories. The independent variables should have at least one within-subjects factor or numeric predictor. There also must be a repeated subject identifier to be used as a random factor.

Usage

glmer.mp(formula, data, ...)

Arguments

formula

A formula object in the style of, e.g., Y ~ X1*X2 + (1|PId), where X1 and X2 are factors or predictors and PId is a factor serving as a subject identifier. The response Y must be of type factor. See the formula entry for glmer.

data

A data frame in long-format. See the data entry for glmer.

...

Additional arguments to be passed to glmer. Most often, these additional arguments are used to specify alternate optimizers. (See Note, below.) These additional arguments must not pass formula, data, or family arguments. See glmer for valid arguments.

Details

This function should be used for nominal response data with repeated measures. In essence, it provides for the equivalent of glmer with family=multinomial, were that option to exist. (That option does not exist, which was a key motivation for developing this function.)

For polytomous response data with only between-subjects factors, use glm.mp or multinom.

Users wishing to verify the correctness of glmer.mp should compare its Anova.mp results to Anova results for models built with glmer using family=binomial for dichotomous responses. The results should be similar.

Post hoc pairwise comparisons for factors can be conducted with glmer.mp.con.

Value

A mixed-effects Poisson regression model of type merMod, specifically of subclass glmerMod. See the return value for glmer.

Note

It is not uncommon to receive a boundary (singular) fit message. This message can often be ignored provided the test output looks sensible.

Sometimes, glmer.mp can fail to converge. Convergence issues can often be remedied by changing the optimizer or its control parameters. For example, the following code uses the bobyqa optimizer and increases the maximum number of function evaluations to 100,000:

m = glmer.mp(Y ~ X + (1|PId), data=df, control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=1e+05)))

Other available optimizer strings besides "bobyqa" include "nloptwrap", "nlminbwrap", and "Nelder_Mead". Additional optimizers are available via the optimx library by passing "optimx" to optimizer and method="name" in the optCtrl parameter list. Eligible names include "nlm", "BFGS", and "L-BFGS-B", among others. See the optimizer argument in glmerControl and the details for optimx for more information.

Author(s)

Jacob O. Wobbrock

References

Baker, S.G. (1994). The multinomial-Poisson transformation. The Statistician 43 (4), pp. 495-504. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/2348134")}

Chen, Z. and Kuo, L. (2001). A note on the estimation of the multinomial logit model with random effects. The American Statistician 55 (2), pp. 89-95. https://www.jstor.org/stable/2685993

Guimaraes, P. (2004). Understanding the multinomial-Poisson transformation. The Stata Journal 4 (3), pp. 265-273. https://www.stata-journal.com/article.html?article=st0069

Lee, J.Y.L., Green, P.J.,and Ryan, L.M. (2017). On the “Poisson trick” and its extensions for fitting multinomial regression models. arXiv preprint available at \Sexpr[results=rd]{tools:::Rd_expr_doi("10.48550/arXiv.1707.08538")}

See Also

Anova.mp(), glmer.mp.con(), glm.mp(), glm.mp.con(), lme4::glmer(), lme4::glmerControl()

Examples

library(multpois)
library(car)
library(lme4)
library(lmerTest)

## two within-subjects factors (x1,X2) with dichotomous response (Y)
data(ws2, package="multpois")

ws2$PId = factor(ws2$PId)
ws2$Y = factor(ws2$Y)
ws2$X1 = factor(ws2$X1)
ws2$X2 = factor(ws2$X2)
contrasts(ws2$X1) <- "contr.sum"
contrasts(ws2$X2) <- "contr.sum"

m1 = glmer(Y ~ X1*X2 + (1|PId), data=ws2, family=binomial)
Anova(m1, type=3)

m2 = glmer.mp(Y ~ X1*X2 + (1|PId), data=ws2) # compare
Anova.mp(m2, type=3)

## two within-subjects factors (x1,X2) with polytomous response (Y)
data(ws3, package="multpois")

ws3$PId = factor(ws3$PId)
ws3$Y = factor(ws3$Y)
ws3$X1 = factor(ws3$X1)
ws3$X2 = factor(ws3$X2)
contrasts(ws3$X1) <- "contr.sum"
contrasts(ws3$X2) <- "contr.sum"

m3 = glmer.mp(Y ~ X1*X2 + (1|PId), data=ws3)
Anova.mp(m3, type=3)


multpois documentation built on April 3, 2025, 9:37 p.m.