Models the counts across two or more mutually exclusive categories from a
fixed number of trials, in long format: one value per category per
trial, with group identifying which rows belong to the same trial. All
rows sharing a group must have the same size, and their prob values
must sum to 1.
Arguments
- size
A non-negative whole numeric vector of the number of trials.
- prob
A numeric vector of the probability of the category. Must sum to 1 across the rows sharing the same
group.NAinsizeorprobfor any row of a trial makes the sampleNAfor every row of that trial, since a trial's categories are drawn jointly.- group
A vector identifying which rows belong to the same multinomial trial (whose
xvalues sum tosizeandprobvalues sum to 1). Every group must have at least 2 rows and the same number of rows as the rest of the data (a fixed set of categories, as in multinomial logistic regression), and must not containNA.
Details
Unlike the other ran_*() functions, ran_multinom() has no n
argument: the number of samples is fully determined by length(prob)
(equivalently length(group)), since a trial's categories can't be
generated independently of one another.
References
Johnson, N.L., Kotz, S., and Balakrishnan, N. 1997. Discrete Multivariate Distributions. John Wiley and Sons, New York.
Gelman, A., Meng, X.-L., and Stern, H. 1996. Posterior predictive assessment of model fitness via realized discrepancies. Statistica Sinica 6(4): 733-807.
