
simEval(d, sideInf, lower.tri = FALSE, cores = 1, ...)
vector
or a square symmetric matrix
(or data.frame
) of similarity/dissimilarity scores between samples of a given dataset (see lower.tri
).vector
containing the side information corresponding to the samples in the dataset from which the similarity/dissimilarity matrix was computed. It can be either a numeric vector (continuous variable) or a factor (discrete variable). If it ilogical
indicating whether the input similarities/dissimilarities are given as a vector
of the lower triangle of the distance matrix (as returned e.g. by base::dist
) or as a square symmetric matrix
(orsimEval
returns a list
with the following components:
eval
firstNN
data.frame
containing the original side informative variable in the first column and the side informative values of the corresponding nearest neighbours in the second columnsideInf
is a numeric vector
the root mean square of differences (RMSD) is used for assessing the similarity between the samples and their corresponding most similar samples in terms of the side information provided. It is computed as follows:
It can be computed as:
sideInf
is a factor the kappa index ($\kappa$) is used instead the RMSD. It is computed as follows:
cores
parameter) is based on OpenMP and hence works only on windows and linux.require(prospectr)
data(NIRsoil)
Yr <- NIRsoil$Nt[as.logical(NIRsoil$train)]
Xr <- NIRsoil$spc[as.logical(NIRsoil$train),]
# Example 1
# Compute a principal components distance
pca.d <- orthoDiss(Xr = Xr, pcSelection = list("cumvar", 0.999),
method = "pca",
local = FALSE,
center = TRUE, scaled = TRUE)
# The final number of pcs used for computing the distance
# matrix of objects in Xr
pca.d$n.components
# The final distance matrix
ds <- pca.d$dissimilarity
# Example 1.1
# Evaluate the distance matrix on the baisis of the
# side information (Yr) associated with Xr
se <- simEval(d = ds, sideInf = Yr)
# The final evaluation results
se$eval
# The final values of the side information (Yr) and the values of
# the side information corresponding to the first nearest neighbours
# found by using the distance matrix
se$firstNN
# Example 1.2
# Evaluate the distance matrix on the baisis of two side
# information (Yr and Yr2)
# variables associated with Xr
Yr2 <- NIRsoil$CEC[as.logical(NIRsoil$train)]
se2 <- simEval(d = ds, sideInf = cbind(Yr, Yr2))
# The final evaluation results
se2$eval
# The final values of the side information variables and the values
# of the side information variables corresponding to the first
# nearest neighbours found by using the distance matrix
se2$firstNN
###
# Example 2
# Evaluate the distances produced by retaining different number of
# principal components (this is the same principle used in the
# optimized principal components approach ("opc"))
# first project the data
pca <- orthoProjection(Xr = Xr, method = "pca",
pcSelection = list("manual", 30),
center = TRUE, scaled = TRUE)
# standardize the scores
scores.s <- sweep(pca$scores, MARGIN = 2,
STATS = pca$sc.sdv, FUN = "/")
rslt <- matrix(NA, ncol(scores.s), 3)
colnames(rslt) <- c("pcs", "rmsd", "r")
rslt[,1] <- 1:ncol(scores.s)
for(i in 1:ncol(scores.s))
{
sc.ipcs <- scores.s[ ,1:i, drop = FALSE]
di <- fDiss(Xr = sc.ipcs, method = "euclid",
center = FALSE, scaled = FALSE)
se <- simEval(d = di, sideInf = Yr)
rslt[i,2:3] <- unlist(se$eval)
}
plot(rslt)
###
# Example 3
# Example 3.1
# Evaluate a dissimilarity matrix computed using a moving window
# correlation method
mwcd <- mcorDiss(Xr = Xr, ws = 35, center = FALSE, scaled = FALSE)
se.mw <- simEval(d = mwcd, sideInf = Yr)
se.mw$eval
# Example 3.2
# Evaluate a dissimilarity matrix computed using the correlation
# method
cd <- corDiss(Xr = Xr, center = FALSE, scaled = FALSE)
se.nc <- simEval(d = cd, sideInf = Yr)
se.nc$eval
Run the code above in your browser using DataLab