View source: R/dissimilarity.R
dissimilarity | R Documentation |
This is a wrapper to integrate the different dissimilarity functions of the offered by package.It computes the dissimilarities between observations in numerical matrices by using an specifed dissmilarity measure.
dissimilarity(Xr, Xu = NULL,
diss_method = c("pca", "pca.nipals", "pls", "mpls",
"cor", "euclid", "cosine", "sid"),
Yr = NULL, gh = FALSE, pc_selection = list("var", 0.01),
return_projection = FALSE, ws = NULL,
center = TRUE, scale = FALSE, documentation = character(),
...)
Xr |
a matrix of containing |
Xu |
an optional matrix containing data of a second set of observations
with |
diss_method |
a character string indicating the method to be used to compute the dissimilarities between observations. Options are:
|
Yr |
a numeric matrix of
|
gh |
a logical indicating if the Mahalanobis distance (in the pls score space) between each observation and the pls centre/mean must be computed. |
pc_selection |
a list of length 2 to be passed onto the
The default is Optionally, the |
return_projection |
a logical indicating if the projection(s) must be
returned. Projections are used if the |
ws |
an odd integer value which specifies the window size, when
|
center |
a logical indicating if |
scale |
a logical indicating if |
documentation |
an optional character string that can be used to
describe anything related to the |
... |
other arguments passed to the dissimilarity functions
( |
This function is a wrapper for ortho_diss
, cor_diss
,
f_diss
, sid
. Check the documentation of these
functions for further details.
A list with the following components:
dissimilarity
: the resulting dissimilarity matrix.
projection
: an ortho_projection
object. Only output
if return_projection = TRUE
and if diss_method = "pca"
,
diss_method = "pca.nipals"
, diss_method = "pls"
or
diss_method = "mpls"
.
This object contains the projection used to compute
the dissimilarity matrix. In case of local dissimilarity matrices,
the projection corresponds to the global projection used to select the
neighborhoods (see ortho_diss
function for further
details).
gh
: a list containing the GH distances as well as the
pls projection used to compute the GH.
Shenk, J., Westerhaus, M., and Berzaghi, P. 1997. Investigation of a LOCAL calibration procedure for near infrared instruments. Journal of Near Infrared Spectroscopy, 5, 223-232.
Westerhaus, M. 2014. Eastern Analytical Symposium Award for outstanding Wachievements in near infrared spectroscopy: my contributions to Wnear infrared spectroscopy. NIR news, 25(8), 16-20.
ortho_diss
cor_diss
f_diss
sid
.
library(prospectr)
data(NIRsoil)
# Filter the data using the first derivative with Savitzky and Golay
# smoothing filter and a window size of 11 spectral variables and a
# polynomial order of 4
sg <- savitzkyGolay(NIRsoil$spc, m = 1, p = 4, w = 15)
# Replace the original spectra with the filtered ones
NIRsoil$spc <- sg
Xu <- NIRsoil$spc[!as.logical(NIRsoil$train), ]
Yu <- NIRsoil$CEC[!as.logical(NIRsoil$train)]
Yr <- NIRsoil$CEC[as.logical(NIRsoil$train)]
Xr <- NIRsoil$spc[as.logical(NIRsoil$train), ]
Xu <- Xu[!is.na(Yu), ]
Xr <- Xr[!is.na(Yr), ]
Yu <- Yu[!is.na(Yu)]
Yr <- Yr[!is.na(Yr)]
dsm_pca <- dissimilarity(
Xr = Xr, Xu = Xu,
diss_method = c("pca"),
Yr = Yr, gh = TRUE,
pc_selection = list("opc", 30),
return_projection = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.