ASt
ASt

Reputation: 21

Joint hypothesis test with marginaleffects::hypotheses from a nnet::multinom object

I have a multinomial logistic regression model, fitted with nnet::multinom(). My outcome has three categories and I have used one predictor in the model. Ultimately I want to jointly test the null hypothesis of the equality of the predicted probabilities (calculated for specific values of the predictor) for a specific category of my outcome.

My code:

library(nnet)
library(marginaleffects)

mod <- multinom(factor(gear) ~ mpg, data = mtcars, trace = FALSE) # fit the model

pred <- predictions(mod, newdata = data.frame(mpg = c(10, 20, 25))) # predicted probabilities for particular values of my predictor

hypotheses(pred, hypothesis = c("b1 = b2", "b1 = b3"), joint = TRUE) # jointly test the null hypothesis of the equality of probabilities of the first category

The error I get:

Error: Could not extract sample size from model object.

I can run:

hypotheses(pred, hypothesis = c("b1 = b2", "b1 = b3"))

But that tests each hypothesis separately.

Any ideas?

Upvotes: 2

Views: 55

Answers (0)

Related Questions