Questions tagged [multinomial]

The multinomial distribution provides a probability distribution over three or more possible outcomes. It generalizes the more fundamental binomial distribution (two outcomes).

In probability theory, the multinomial distribution generalizes the binomial distribution to three or more outcomes.

Suppose two chess players had played numerous games, from which we estimate that Player A would win with probability 0.40, Player B would win with probability 0.35, and the probability that the game ends in a draw is 0.25. The multinomial distribution can be used to answer questions like:

  1. If these two chess players played 12 games, what is the expected number of wins, losses, and draws for player A?
  2. If these two chess players play 3 games, what is the probability that A wins one, B, wins one, and they draw on the other?

Binary classification/prediction methods (such as logistic regression) can also be generalized for multinomial outcomes (i.e., three or more class labels). Multinomial logistic regression is also sometimes called a maximum entropy (MaxEnt) model.

421 questions
49
votes
7 answers

multinomial logistic multilevel models in R

Problem: I need to estimate a set of multinomial logistic multilevel models and can’t find an appropriate R package. What is the best R package to estimate such models? STATA 13 recently added this feature to their multilevel mixed-effects models –…
Raphael
  • 1,143
  • 1
  • 11
  • 16
19
votes
1 answer

R: Tukey posthoc tests for nnet multinom multinomial fit to test for overall differences in multinomial distribution

I fitted a mutinomial model using nnet's multinom function using (in this case on data giving the diet preference of male and female and different size classes of alligators in different lakes)…
Tom Wenseleers
  • 7,535
  • 7
  • 63
  • 103
19
votes
4 answers

Dealing with negative values in sklearn MultinomialNB

I am normalizing my text input before running MultinomialNB in sklearn like this: vectorizer = TfidfVectorizer(max_df=0.5, stop_words='english', use_idf=True) lsa = TruncatedSVD(n_components=100) mnb = MultinomialNB(alpha=0.01) train_text =…
seanlorenz
  • 323
  • 1
  • 3
  • 7
18
votes
2 answers

Multinomial logit in R: mlogit versus nnet

I want to run a multinomial logit in R and have used two libraries, nnet and mlogit, which produce different results and report different types of statistics. My questions are: What is the source of discrepency between the coefficients and standard…
splinter
  • 3,727
  • 8
  • 37
  • 82
11
votes
2 answers

numpy.random.multinomial at version 1.16.6 is 10x faster than later version

Here are codes and result: python -c "import numpy as np; from timeit import timeit; print('numpy version {}: {:.1f} seconds'.format(np.__version__, timeit('np.random.multinomial(1, [0.1, 0.2, 0.3, 0.4])', number=1000000,…
Winston Guo
  • 111
  • 2
11
votes
1 answer

In gbm multinomial dist, how to use predict to get categorical output?

My response is a categorical variable (some alphabets), so I used distribution='multinomial' when making the model, and now I want to predict the response and obtain the output in terms of these alphabets, instead of matrix of probabilities. However…
shavendy
  • 173
  • 1
  • 1
  • 10
10
votes
0 answers

How to run a multinomial logit regression with both individual and time fixed effects in R

Long story short: I need to run a multinomial logit regression with both individual and time fixed effects in R. I thought I could use the packages mlogit and survival to this purpose, but I am cannot find a way to include fixed effects. Now the…
shazz
  • 387
  • 1
  • 13
10
votes
2 answers

R How to get confidence interval for multinominal logit?

Let me use UCLA example on multinominal logit as a running example--- library(nnet) library(foreign) ml <- read.dta("http://www.ats.ucla.edu/stat/data/hsbdemo.dta") ml$prog2 <- relevel(ml$prog, ref = "academic") test <- multinom(prog2 ~ ses +…
user2966726
  • 101
  • 1
  • 1
  • 3
9
votes
2 answers

Sampling without replacement from a given non-uniform distribution in TensorFlow

I'm looking for something similar to numpy.random.choice(range(3),replacement=False,size=2,p=[0.1,0.2,0.7]) in TensorFlow. The closest Op to it seems to be tf.multinomial(tf.log(p)) which takes logits as input but it can't sample without…
TNM
  • 1,361
  • 3
  • 15
  • 25
9
votes
2 answers

GBM multinomial distribution, how to use predict() to get predicted class?

I am using the multinomial distribution from the gbm package in R. When I use the predict function, I get a series of values: 5.086328 -4.738346 -8.492738 -5.980720 -4.351102 -4.738044 -3.220387 -4.732654 but I want to get the probability of each…
Jim Johnson
  • 93
  • 1
  • 4
8
votes
3 answers

How to get average marginal effects (AMEs) with standard errors of a multinomial logit model?

I want to get the average marginal effects (AME) of a multinomial logit model with standard errors. For this I've tried different methods, but they haven't led to the goal so far. Best attempt My best attempt was to get the AMEs by hand using mlogit…
jay.sf
  • 60,139
  • 8
  • 53
  • 110
8
votes
2 answers

Fitted values for multinom in R: Coefficients for Reference Category?

I'm using the function multinom from the nnet package to run a multinomial logistic regression. In multinomial logistic regression, as I understand it, the coefficients are the changes in the log of the ratio of the probability of a response over…
jflournoy
  • 763
  • 1
  • 8
  • 23
8
votes
1 answer

How to predict with multinom() in R

I'm trying to calculate predicted probabilities using specific values, but R shows the following error: Error in model.frame.default(Terms, newdata, na.action = na.omit, xlev = object$xlevels) : variable lengths differ (found for 'x') In…
user1172558
  • 655
  • 4
  • 12
  • 18
7
votes
3 answers

Efficient multinomial sampling when sample size and probability vary

This question pertains to efficient sampling from multinomial distributions with varying sample sizes and probabilities. Below I describe the approach I have used, but wonder whether it can be improved with some intelligent vectorisation. I'm…
jbaums
  • 27,115
  • 5
  • 79
  • 119
7
votes
1 answer

Multinomial regression using multinom function in R

I was thinking about posting my question in Cross-Validated, but decided to come here. I am using the multinom() function from the nnet package to estimate the odds of becoming employed, unemployed, or out of labor force conditioned on age and…
Koba
  • 1,514
  • 4
  • 27
  • 48
1
2 3
27 28