predict_qda function

Quadratic discrimination prediction

Quadratic discrimination prediction

The function uses the output from the function qda

(Section A.3.2) and a PP-vector XX, and calculates the predicted group for this XX.

predict_qda(qd, newx)

Arguments

  • qd: The output from qda.
  • newx: A PP-vector XX whose components match the variables used in the qda function.

Returns

A KK-vector of the discriminant values dkQ(X)d_k^Q(X) in (11.48) for the given XX.

Examples

# Load Iris Data data(iris) # Build data x.iris <- as.matrix(iris[, 1:4]) n <- nrow(x.iris) # Gets group vector (1, ... , 1, 2, ..., 2, 3, ... , 3) y.iris <- rep(1:3, c(50, 50, 50)) # Perform QDA qd.iris <- qda(x.iris, y.iris) yhat.qd <- NULL for (i in seq_len(n)) { yhat.qd <- c(yhat.qd, imax(predict_qda(qd.iris, x.iris[i, ]))) } table(yhat.qd, y.iris)

See Also

qda, imax

  • Maintainer: James Balamuta
  • License: MIT + file LICENSE
  • Last published: 2020-10-31