Description Usage Arguments Value See Also Examples
The function uses the output from the function qda
(Section A.3.2) and a P-vector X, and calculates the predicted
group for this X.
1 | predict_qda(qd, newx)
|
qd |
The output from |
newx |
A P-vector X whose components match the variables
used in the |
A K-vector of the discriminant values d_k^Q(X) in (11.48) for the given X.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.