cm.rbd3 | R Documentation |
This function computes the squared Pearson correlation (R^2
) between a response vector x
and a derived variable V
for every possible combination of three distinct spectral bands. The derived variable V
is calculated using the formula:
V = \frac{R_k - R_j}{R_j - R_i}
where R_i
, R_j
, and R_k
represent the reflectance values at bands i
, j
, and k
, respectively.
cm.rbd3(
S,
x,
w = wavelength(S),
w.unit = NULL,
cm.plot = FALSE,
plot.method = "default"
)
S |
A spectral data object or matrix. Each column corresponds to a spectral band. |
x |
A numeric vector representing the response variable (e.g., chlorophyll). |
w |
A numeric vector of wavelengths; by default, it is derived using |
w.unit |
Character string specifying the unit of wavelengths (optional). |
cm.plot |
Logical. If |
plot.method |
Character string specifying the plotting method. Currently, the plotting option uses |
The function prints the maximum R^2
value and the corresponding band wavelengths. Optionally, it can produce a 3D slice plot
of the correlation array using plot3D::slice3D
.
For every combination of three distinct bands (i
, j
, k
), the function computes
V = \frac{R_k - R_j}{R_j - R_i}
and then calculates the squared Pearson correlation between x
and V
.
The maximum R^2
value and its associated band combination are printed.
If cm.plot
is set to TRUE
, the function generates a 3D slice plot of the correlation array using the best band combination,
where the slices correspond to the wavelengths of the bands.
A 3-dimensional array of squared correlation (R^2
) values with dimensions corresponding to the
combinations of bands i
, j
, and k
.
## Not run:
library(visa)
data(NSpec.DF)
x <- NSpec.DF$N # nitrogen
# Below resamples spectra to 20 nm for fast computation
S <- NSpec.DF$spectra[, seq(1, ncol(NSpec.DF$spectra), 20)]
# S is a spectral data object and x is a numeric vector.
Rsq3 <- cm.rbd3(S, x, cm.plot = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.