qda.Rd
Quadratic discriminant analysis.
qda(x, ...) # S3 method for formula qda(formula, data, ..., subset, na.action) # S3 method for default qda(x, grouping, prior = proportions, method, CV = FALSE, nu, ...) # S3 method for data.frame qda(x, ...) # S3 method for matrix qda(x, grouping, ..., subset, na.action)
formula | A formula of the form |
---|---|
data | Data frame from which variables specified in |
x | (required if no formula is given as the principal argument.) a matrix or data frame or Matrix containing the explanatory variables. |
grouping | (required if no formula principal argument is given.) a factor specifying the class for each observation. |
prior | the prior probabilities of class membership. If unspecified, the class proportions for the training set are used. If specified, the probabilities should be specified in the order of the factor levels. |
subset | An index vector specifying the cases to be used in the training sample. (NOTE: If given, this argument must be named.) |
na.action | A function to specify the action to be taken if |
method |
|
CV | If true, returns results (classes and posterior probabilities) for leave-out-out cross-validation. Note that if the prior is estimated, the proportions in the whole dataset are used. |
nu | degrees of freedom for |
... | arguments passed to or from other methods. |
an object of class "qda"
containing the following components:
the prior probabilities used.
the group means.
for each group i
, scaling[,,i]
is an array which transforms observations
so that within-groups covariance matrix is spherical.
a vector of half log determinants of the dispersion matrix.
the levels of the grouping factor.
(if formula is a formula) an object of mode expression and class term summarizing the formula.
the (matched) function call.
The MAP classification (a factor)
posterior probabilities for the classes
Uses a QR decomposition which will give an error message if the within-group variance is singular for any group.
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.
Ripley, B. D. (1996) Pattern Recognition and Neural Networks. Cambridge University Press.
tr <- sample(1:50, 25) train <- rbind(iris3[tr,,1], iris3[tr,,2], iris3[tr,,3]) test <- rbind(iris3[-tr,,1], iris3[-tr,,2], iris3[-tr,,3]) cl <- factor(c(rep("s",25), rep("c",25), rep("v",25))) z <- qda(train, cl) predict(z,test)$class#> [1] s s s s s s s s s s s s s s s s s s s s s s s s s c c c c c c c c c c c c c #> [39] c c c c c c c c c c c c v v v v v v v v v v v v v v v v v v v v v v v v v #> Levels: c s v