A localized version of Linear Discriminant Analysis.
latin1
loclda(x,...)## S3 method for class 'formula'loclda(formula, data,..., subset, na.action)## Default S3 method:loclda(x, grouping, weight.func =function(x)1/exp(x), k = nrow(x), weighted.apriori =TRUE,...)## S3 method for class 'data.frame' loclda(x,...)## S3 method for class 'matrix'loclda(x, grouping,..., subset, na.action)
Arguments
formula: Formula of the form ‘groups ~ x1 + x2 + ...’ .
data: Data frame from which variables specified in formula are to be taken.
x: Matrix or data frame containing the explanatory variables (required, if formula is not given).
grouping: (required if no formula principal argument is given.) A factor specifying the class for each observation.
weight.func: Function used to compute local weights. Must be finite over the interval [0,1]. See Details below.
k: Number of nearest neighbours used to construct localized classification rules. See Details below.
weighted.apriori: Logical: if TRUE, class prior probabilities are computed using local weights (see Details below). If FALSE, equal priors for all classes actually occurring in the train data are used.
subset: An index vector specifying the cases to be used in the training sample.
na.action: A function to specify the action to be taken if NAs are found. The default action is for the procedure to fail. An alternative is na.omit
which leads to rejection of cases with missing values on any required variable.
...: Further arguments to be passed to loclda.default.
Details
This is an approach to apply the concept of localization described by Tutz and Binder (2005) to Linear Discriminant Analysis. The function loclda generates an object of class loclda
(see Value below). As localization makes it necessary to build an individual decision rule for each test observation, this rule construction has to be handled by predict.loclda. For convenience, the rule building procedure is still described here.
To classify a test observation xs, only the k nearest neighbours of xs within the train data are used. Each of these k train observations xi,i=1,...,k, is assigned a weight wi according to
where K is the weighting function given by weight.func, ∣∣xi−xs∣∣
is the euclidian distance of xi and xs
and dk is the euclidian distance of xs
to its k-th nearest neighbour. With these weights for each class Ag,g=1,...,G, its weighted empirical mean mu_g_hat and weighted empirical covariance matrix are computed. The estimated pooled (weighted) covariance matrix Sigmahat is then calculated from the individual weighted empirical class covariance matrices. If weighted.apriori is TRUE (the default), prior class probabilities are estimated according to:
where I is the indicator function. If FALSE, equal priors for all classes are used. In analogy to Linear Discriminant Analysis, the decision rule for xs is