classify_multiclass {sim2Dpredictr} | R Documentation |
Classify subjects based on predicted probabilities for each class
Description
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.
Usage
classify_multiclass(
predicted.probs = NULL,
category.names,
keep.probs = TRUE,
B = NULL,
X = NULL,
X.incl.X0 = FALSE
)
Arguments
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 |
Details
Classification for each subject is determined based on the category with highest predicted probability.
Value
Depending on the option selected for keep.probs
, returns a
data frame or vector.
Examples
## 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)