View source: R/discriminant.qda.R
discriminant.qda | R Documentation |
Performs discriminant analysis for two groups, under the assumption of equal, CPC or unrelated population covariance matrices.
discriminant.qda(origdata, group, method = c("unbiased", "pooled", "cpc", "fullcpccrossvalid"), B = NULL, standardize = FALSE)
origdata |
Matrix containing the sample data for two groups. |
group |
Vector (with values 1 and 2) indicating group membership for the rows in |
method |
Options: |
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. |
Returns a list with the following components:
inputdata |
The observations in |
misclassrate |
The misclasssification error rate. |
Theo Pepler
Pepler, P.T. (2014). The identification and application of common principal components. PhD dissertation in the Department of Statistics and Actuarial Science, Stellenbosch University.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.