How to run a multinomial logistic regression with mixed effects in R?

I'm trying to run a multinomial logistic regression with mixed effects. Let's say I have the following variables:

Participant (ten participants, each with 10 observations) Word (ten different words, each participant sees each once) IV (some two level grouping variable) DV (can be 1, 2 or 3)

How would I run a multinomial logistic regression with ppt and word as random variables?

Here is some sample data:

ppt <- rep(1:10, each = 10)
word <- rep(1:10, times = 10)
IV <- rep(1:2, times = 50)
DV <- sample(x = c(1,2,3), size = 100, replace = TRUE)

d <- as.data.frame(cbind(ppt, word, IV, DV))

• The package mclogit seems to provide this functionality. Jan 5 at 8:32

1 Answer

I think one way to do this is with the glmnet package,

glmnet: Lasso and Elastic-Net Regularized Generalized Linear Models.
Extremely efficient procedures for fitting the entire lasso or elastic-net regularization path for linear regression, logistic and multinomial regression models, Poisson regression, Cox model, multiple-response Gaussian, and the grouped multinomial regression.

You need to install glmnet and its dependencies first, and R compiles a lot of C/C++ code to do this.

ppt <- rep(1:10, each = 10)
word <- rep(1:10, times = 10)
IV <- rep(1:2, times = 50)
DV <- sample(x = c(1,2,3), size = 100, replace = TRUE)

d <- as.data.frame(cbind(ppt, word, IV, DV))

# basic usage:
library(glmnet)
fit <- glmnet(as.matrix(d[,1:3]), d\$DV, family = "multinomial")
summary(fit)


Maybe ask this at stats.stackexchange.com, the real experts are over there.

• glmnet to my knowledge does not incorporate random effects, and it tries to remove variables which would not be a good idea in this (and most other) context. Jan 5 at 8:25
• Thanks I was indeed not sure. That question was asked in a different forum, and the example was a toy example.
– knb
Jan 5 at 8:28
• Binary logistic regression is easier to do than multinomial logistic regression, and binary regression requires 96 participants just to estimate the overall intercept. So I don't know how this project is going to work with 10 participants. Categorical outcome variables have minimum information. Nov 22 at 22:23