Learn R Programming

visa (version 1.0.0)

cm.nsr: Selecting the best 2-Band combinations for Normalized Simple Ratio (NSR)

Description

This function develops an optimization algorithm based on correlation analysis between the spectral matrix spectra and the vegetation variable of interest x. It determines the best spectral band combinations (i, j) of the full spectrum that are most predictive for x.

Usage

cm.nsr(S, x, w = wavelength(S), w.unit = NULL, cm.plot = FALSE)

Value

cm

A correlation coefficient matrix with squared Pearson correlation values.

Arguments

S

A matrix of spectral data, where each row is a spectrum across all spectral bands.

x

A numeric vector (e.g., a vegetation variable).

w

A numeric vector of wavelengths; by default it is derived using wavelength(S).

w.unit

A character string specifying the unit of wavelengths (default is NULL).

cm.plot

Logical. If TRUE, the correlation coefficient matrix is plotted.

Details

For every possible pair of distinct bands (i, j), the function calculates $$ \mathrm{NSR} = \frac{R_j - R_i}{R_j + R_i} $$ and then computes the squared Pearson correlation (\(R^2\)) between x and the resulting NSR values.

If the two bands are identical or the standard deviation of computed VI (for a given band combination) is zero, the correlation is set to 0, thereby avoiding warnings.

See Also

Examples

Run this code
if (FALSE) {
  library(visa)
  data(NSpec.DF)
  X <- NSpec.DF$spectra[, seq(1, ncol(NSpec.DF$spectra), 5)]  # resampled to 5 nm steps
  y <- NSpec.DF$N  # nitrogen
  cm <- cm.nsr(X, y, cm.plot = TRUE)
}

Run the code above in your browser using DataLab