dadis | R Documentation |
Discriminant analysis using the dissimilarities (e.g. Euclidean or Mahalanobis distances) to the class centers.
For each observation to predict, the function calculates the dissimilarity between this observation and each of the class centers of the reference (= training) data. The final predicted class corresponds to the class for which the dissimilarity is the lowest.
dadis(Xr, Yr, Xu, Yu = NULL,
diss = c("euclidean", "mahalanobis", "correlation"), sigma = NULL)
Xr |
A |
Yr |
A vector of length |
Xu |
A |
Yu |
A vector of length |
diss |
Type of dissimilarity used. Possible values are "euclidean" (Euclidean distances; default), "mahalanobis" (Mahalanobis distances), or "correlation" (correlation dissimilarities, calculated by |
sigma |
The covariance matrix (weight matrix) used for the Mahalanobis distance. If |
A list of outputs, such as:
y |
Responses for the test data. |
fit |
Predictions for the test data. |
r |
Residuals for the test data. |
data(iris)
X <- iris[, 1:4]
y <- iris[, 5]
N <- nrow(X)
m <- round(.25 * N)
n <- N - m
s <- sample(1:N, m)
Xr <- X[-s, ]
yr <- y[-s]
Xu <- X[s, ]
yu <- y[s]
fm <- dadis(Xr, yr, Xu, yu)
names(fm)
headm(fm$y)
headm(fm$fit)
headm(fm$r)
fm$ni
err(fm)
fm <- dadis(Xr, yr, Xu, yu, diss = "mahalanobis")
err(fm)
nclas <- length(unique(yr))
W <- matW(Xr, yr)$W * n / (n - nclas)
fm <- dadis(Xr, yr, Xu, yu, diss = "mahalanobis", sigma = W)
err(fm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.