Skip to contents

delta_k(x) = x' S^-1 mu_k - mu_k' S^-1 mu_k / 2 + log pi_k with the pooled covariance S (divisor N - K) and priors n_k / N (ESL eq 4.10); classify to the largest.

Usage

morie_esl_lda_disc(X, y, query = NULL)

Arguments

X

Training predictors, N by p.

y

Class labels.

query

Points to score (default X).

Value

Named list: estimate, prediction, discriminants (query rows by K), classes, priors, means (K by p), pooled_covariance, n, p, K.

References

Hastie, Tibshirani & Friedman (2009), sec. 4.3.

Examples

i <- 1:30
X <- cbind(sin(i), cos(3 * i) + (i %% 3))
morie_esl_lda_disc(X, i %% 3, rbind(c(0, 1)))$prediction
#> [1] 1