cor_diss {resemble} | R Documentation |
Correlation and moving correlation dissimilarity measurements (cor_diss)
Description
Computes correlation and moving correlation dissimilarity matrices.
Usage
cor_diss(Xr, Xu = NULL, ws = NULL,
center = TRUE, scale = FALSE)
Arguments
Xr |
a matrix. |
Xu |
an optional matrix containing data of a second set of observations. |
ws |
for moving correlation dissimilarity, an odd integer value which
specifies the window size. If |
center |
a logical indicating if the spectral data |
scale |
a logical indicating if |
Details
The correlation dissimilarity \(d\) between two observations \(x_i\) and \(x_j\) is based on the Perason's correlation coefficient (\(\rho\)) and it can be computed as follows:
\[d(x_i, x_j) = \frac{1}{2}((1 - \rho(x_i, x_j)))\]The above formula is used when ws = NULL
.
On the other hand (when ws != NULL
) the moving correlation
dissimilarity between two observations \(x_i\) and \(x_j\)
is computed as follows:
where \(ws\) represents a given window size which rolls sequentially from 1 up to \(p - ws\) and \(p\) is the number of variables of the observations.
The function does not accept input data containing missing values.
Value
a matrix of the computed dissimilarities.
Author(s)
Antoine Stevens and Leonardo Ramirez-Lopez
Examples
library(prospectr)
data(NIRsoil)
Xu <- NIRsoil$spc[!as.logical(NIRsoil$train), ]
Xr <- NIRsoil$spc[as.logical(NIRsoil$train), ]
cor_diss(Xr = Xr)
cor_diss(Xr = Xr, Xu = Xu)
cor_diss(Xr = Xr, ws = 41)
cor_diss(Xr = Xr, Xu = Xu, ws = 41)