View source: R/prob_multinomial.R
prob_multinomial | R Documentation |
Uses design matrix and parameter estimates to calculate probabilities for each class for each subject.
prob_multinomial(x, b, a0, classify = TRUE)
x |
Design, or input, matrix, of dimension nobs x nvars; each row is
an observation vector. It is recommended that |
b |
A list whose elements are vectors of parameter estimates and whose
names correspond to the values of |
a0 |
A matrix of with |
classify |
Logical. When |
The parameterization employed here is as in Friedman (2010), i.e.,
over-parameterized, which under the elastic net penalty allows for unique
parameter estimates. Thus, there is not a reference class, but each class
has an associated set of parameter estimates. Probabilities are then
obtained by
Pr(Y_i = k | X_i) = \exp(X_i^T B_k) / \sum_{v=1}^V \exp(X_i^T B_v)
where X_i is a the design matrix for subject i, V is the number of classes,
and B_v is the vector of parameters associated with class v.
A data frame where each column contains predicted class probabilities for each subject.
Friedman:2010ssnet
x <- matrix(rnorm(10*5), nrow = 10, ncol = 5)
colnames(x) <- paste0("x", seq_len(ncol(x)))
x0 <- cbind(x0 = 1, x)
b <- list(a = runif(5), b = runif(5), c = runif(5))
for (i in seq_len(length(b))) {
names(b[[i]]) <- colnames(x)
}
a0 <- matrix(runif(3), nrow = 3, ncol= 1)
prob_multinomial(x = x, b = b, a0 = a0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.