View source: R/classify_multiclass.R
classify_multiclass | R Documentation |
Classify subjects based on predicted probabilities for each class. The predicted probabilities can be input by the user or calculated within function using parameter estimates and design matrix for a multinomial regression model.
classify_multiclass(
predicted.probs = NULL,
category.names,
keep.probs = TRUE,
B = NULL,
X = NULL,
X.incl.X0 = FALSE
)
predicted.probs |
A matrix where the number of rows is equal to the
number of subjects and the number of columns equals the number of
categories. |
category.names |
A vector containing the names of each category. The
order of names should match the order of columns in |
keep.probs |
Logical. When |
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 |
Classification for each subject is determined based on the category with highest predicted probability.
Depending on the option selected for keep.probs
, returns a
data frame or vector.
## number of categories
vt <- 3
## covariate values
xt <- matrix(rnorm(10 * 2), ncol = 2, nrow = 10)
## list of parameter vectors (over-parameterized model)
bu <- list(b1 = c(0, 0.25, 0.25),
b2 = c(0, -0.25, -0.25),
b3 = c(0, 0.25, -0.25))
## subject specific probabilities for each category
## (over-parameterized model)
prp <- generate_multinom_probs(V = vt, X = xt, B = bu)
classify_multiclass(predicted.probs = prp,
category.names = c("A", "B", "C"))
## generate predicted probabilities within function
classify_multiclass(predicted.probs = NULL,
category.names = c("A", "B", "C"),
X = xt, B = bu)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.