Models the counts across two or more mutually exclusive categories from a
fixed number of trials, in long format: one row per category per
trial, with group identifying which rows belong to the same trial.
Arguments
- x
A non-negative whole numeric vector of the category counts.
- 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.- 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.- res
A flag specifying whether to return the deviance residual as opposed to the deviance.
Details
A category's deviance depends only on its own x and mu = size * prob,
not on the rest of its trial, so group is used only to validate size
and prob (see log_lik_multinom()), not in the calculation itself.
dev_multinom() is the Poisson-equivalent deviance (see dev_pois()):
summing it over a trial's rows recovers the trial's exact multinomial
deviance.
References
McCullagh, P., and Nelder, J.A. 1989. Generalized Linear Models. 2nd edition. Chapman and Hall, London.
Baker, S.G. 1994. The multinomial-Poisson transformation. The Statistician 43(4): 495-504. doi:10.2307/2348134 .
Agresti, A. 2013. Categorical Data Analysis. 3rd edition. John Wiley and Sons, Hoboken, New Jersey.
