0
$\begingroup$

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))
$\endgroup$
1
  • 1
    $\begingroup$ The package mclogit seems to provide this functionality. $\endgroup$ Commented Jan 5, 2023 at 8:32

1 Answer 1

-1
$\begingroup$

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.

$\endgroup$
3
  • 2
    $\begingroup$ 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. $\endgroup$ Commented Jan 5, 2023 at 8:25
  • $\begingroup$ Thanks I was indeed not sure. That question was asked in a different forum, and the example was a toy example. $\endgroup$
    – knb
    Commented Jan 5, 2023 at 8:28
  • 1
    $\begingroup$ 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. $\endgroup$ Commented Nov 22, 2023 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.