Quadratic discriminant analysis (QDA) using covariance matrices projected via the gips framework to enforce permutation symmetry and improve numerical stability.
Usage
gipsqda(x, ...)
# S3 method for class 'formula'
gipsqda(formula, data, ..., subset, na.action)
# Default S3 method
gipsqda(x, grouping, prior = proportions,
nu = 5, MAP = TRUE, optimizer = NULL, max_iter = NULL, ...)
# S3 method for class 'data.frame'
gipsqda(x, ...)
# S3 method for class 'matrix'
gipsqda(x, grouping, ..., subset, na.action)Arguments
- x
(required if no formula is given as the principal argument) a matrix or data frame containing the explanatory variables.
- ...
Arguments passed to or from other methods.
- formula
A formula of the form
groups ~ x1 + x2 + .... The response is the grouping factor and the right-hand side specifies the (non-factor) discriminators.- data
An optional data frame, list or environment from which variables specified in
formulaare preferentially taken.- grouping
(required if no formula is given) a factor specifying the class for each observation.
- prior
The prior probabilities of class membership. If omitted, training-set class proportions are used. Supplied values must sum to one and match the number of groups.
- nu
Reserved for compatibility with related QDA interfaces; it is not currently used by the covariance projection.
- MAP
Logical; if
TRUE, maximum a posteriori covariance projection is used. IfFALSE, projections are averaged using retained posterior permutation probabilities.- optimizer
Character string specifying the optimization method used for covariance projection. If
NULL, a default choice depending on the problem dimension is used.- max_iter
Maximum number of iterations for stochastic optimizers.
- subset
An index vector specifying the cases to be used in the training sample. (NOTE: must be named.)
- na.action
A function specifying the action to be taken if
NAs are found.
Value
An object of class "gipsqda" containing the following components:
prior: prior probabilities of the groupscounts: number of observations in each groupmeans: group meansscaling: group-specific scaling matrices derived from the projected covariance matricesldet: log-determinants of the projected covariance matriceslev: class labelsN: total number of observationsoptimization_info: information returned by the covariance projection optimizer for the final class projectioncall: the matched callFormula fits additionally contain
terms,contrasts,xlevels, and any recordedna.action.
Details
This function is a minor modification of qda, replacing
the classical sample covariance estimators by projected covariance matrices
obtained using the gips framework.
Quadratic discriminant analysis models each class with its own covariance
matrix. In gipsqda, these covariance matrices are projected using the
gips framework, which enforces permutation symmetry and mitigates
singularity and overfitting in high-dimensional or small-sample settings.
Classification can be performed using plug-in, predictive, debiased,
or leave-one-out cross-validation rules via predict.gipsqda.
Note
The function may be called with either a formula interface or with a matrix
and grouping factor. Arguments subset and na.action, if used,
must be named.
References
Chojecki, A., et al. (2025). Learning Permutation Symmetry of a Gaussian Vector with gips in R. Journal of Statistical Software, 112(7), 1–38. doi:10.18637/jss.v112.i07
Venables, W. N. and Ripley, B. D. (2002). Modern Applied Statistics with S. Fourth edition. Springer.
Examples
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 <- gipsqda(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 v c c c c c c c c c v v v v v v v v v v v v v v v c v v v v v v v v v
#> Levels: c s v