jeudi 11 février 2021

Generating multinomial random data in R

I am trying to generate data from a multinomial distribution in R using the function rmultinom, but I am having some problems. The fact is that I want a data frame of 50 rows and 20 columns and a total sum of the outcomes equal to 3 times n*p.

I am using this code:

p <- 20
n <- 50
N <- 3*(n*p)
prob_true <- rep(1/p, p)
a <- rmultinom(50, N, prob_true)

But I get some very strange results and a data frame with 20 rows and 50 columns. How can I solve this problem?

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire