generate_multinom_probs {sim2Dpredictr} | R Documentation |
Generate Probabilities for Multinomial Draws
Description
Obtain probabilities for each category of a multinomial distribution based on covariate and parameter values based on the logit models for the multinomial distribution.
Usage
generate_multinom_probs(V = NULL, B = NULL, X = NULL, X.incl.X0 = FALSE)
Arguments
V |
A numeric value stating the number of categories desired. |
B |
A list, each element of which contains a parameter vector. The
list should have length |
X |
A matrix, each row of which contains subject covariate/predictor values. |
X.incl.X0 |
Logical. When |
Value
A matrix containing subject-specific probabilities for each
category of the multinomial distribution. The number of rows equals
nrow(X)
and the number of columns equals V
.
References
Agresti A (2007). An Introduction to Categorical Analysis, 2nd edition. John Wiley & Sons, Hoboken, New Jersey.
Friedman J, Hastie T, Tibshirani R (2010). “Regularization paths for generalized linear models via coordinate descent.” Journal of Statistical Software, 33, 1-22. doi:10.18637/jss.v033.i01.
Examples
## number of categories
vt <- 3
## covariate values
xt <- matrix(rnorm(10 * 2), ncol = 2, nrow = 10)
## list of parameter vectors
bt <- list(b1 = c(1, 0.25, -0.25),
b2 = c(-0.5, 0.15, 0.15))
## list of parameter vectors (over-parameterized model)
bu <- list(b1 = c(1, 0.25, -0.25),
b2 = c(-0.5, 0.15, 0.15),
b3 = c(-1, 0.1, -0.20))
## subject specific probabilities for each category
generate_multinom_probs(V = vt, X = xt, B = bt)
## subject specific probabilities for each category
## (over-parameterized model)
generate_multinom_probs(V = vt, X = xt, B = bu)