dis | R Documentation |
Calculation of dissimilarities between the row observations of a data set and a given vector mu
. By default, if not specified, vector mu
is the column means of the reference (= training) data set.
dis(Xr, Xu = NULL, mu = NULL, diss = c("euclidean", "mahalanobis", "correlation"),
sigma = NULL, weights = NULL)
Xr |
A |
Xu |
A |
mu |
The vector of length |
diss |
The type of dissimilarities used. Possible values are "euclidean" (Euclidean distances; default), "mahalanobis" (Mahalanobis distances), or "correlation". Correlation dissimilarities are calculated by |
sigma |
For Mahalanobis distance, the covariance matrix considered. If |
weights |
Only for Mahalanobis distance and when |
A list of outputs, such as:
dr |
A data frame of the dissimilarities for Xr. |
du |
A data frame of the dissimilarities for Xu. |
n <- 8
p <- 6
set.seed(1)
X <- matrix(rnorm(n * p, mean = 10), ncol = p, byrow = TRUE)
y1 <- 100 * rnorm(n)
y2 <- 100 * rnorm(n)
Y <- cbind(y1, y2)
set.seed(NULL)
Xr <- X[1:6, ] ; Yr <- Y[1:6, ]
Xu <- X[7:8, ] ; Yu <- Y[7:8, ]
mu <- NULL
dis(Xr, mu = mu)
dis(Xr, Xu, mu)
fm <- pls(Xr, Yr, ncomp = 3)
dis(fm$Tr, mu = mu, diss = "mahalanobis")
fm <- pls(Xr, Yr, Xu, ncomp = 3)
dis(fm$Tr, fm$Tu, mu, diss = "mahalanobis")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.