discriminant.qda: Discriminant analysis under various assumed covariance matrix...

View source: R/discriminant.qda.R

discriminant.qdaR Documentation

Discriminant analysis under various assumed covariance matrix structures

Description

Performs discriminant analysis for two groups, under the assumption of equal, CPC or unrelated population covariance matrices.

Usage

discriminant.qda(origdata, group, method = c("unbiased", "pooled", "cpc", "fullcpccrossvalid"), B = NULL, standardize = FALSE)

Arguments

origdata

Matrix containing the sample data for two groups.

group

Vector (with values 1 and 2) indicating group membership for the rows in origdata.

method

Options: unbiased (default), cpc, fullcpccrossvalid, pooled. Each method estimates the covariance matrices of the two groups in a different way (under different assumptions). See Pepler (2014) for details.

B

Modal matrix, if available.

standardize

Logical, indicating whether the covariance matrices of the two groups should be calculated on standardised data before performing the discriminant analysis (default = FALSE). Discriminant analysis on the standardised covariance matrices is equivalent to discriminant analysis on the correlation matrices of the two groups.

Value

Returns a list with the following components:

inputdata

The observations in origdata, together with an indication of the group membership and the predicted group membership.

misclassrate

The misclasssification error rate.

Author(s)

Theo Pepler

References

Pepler, P.T. (2014). The identification and application of common principal components. PhD dissertation in the Department of Statistics and Actuarial Science, Stellenbosch University.

Examples

# Discriminant analysis to distinguish between the versicolor 
# and virginica groups, under the CPC assumption.
data(iris)
versicolor <- iris[51:100, 1:4]
virginica <- iris[101:150, 1:4]
S <- array(NA, dim = c(4, 4, 2))
S[, , 1] <- cov(versicolor)
S[, , 2] <- cov(virginica)
nvec <- c(nrow(versicolor), nrow(virginica))
B <- cpc::FG(covmats = S, nvec = nvec)$B
discriminant.qda(origdata = rbind(versicolor, virginica), group = c(rep(1, times = nrow(versicolor)), rep(2, times = nrow(virginica))), method = "cpc", B = B)

tpepler/cpc documentation built on July 7, 2022, 2:13 a.m.