Use linear regression resp. non negative linear regression (package nnls) without intercept to estimate coefficients for a linear combination of reference spectra to represent one or multiple target spectra. For a sparse solution and/or correlated references see omp.

linear_combination(
  targets,
  references,
  references_ids = NULL,
  nonnegative = FALSE
)

Arguments

targets

a hyperSpec object.

references

a hyperSpec object containing the spectra to be combined in in a linear manner.

references_ids

either a single string or numeric specifying the column with names for the references in the object `references`, or a character vector with a name per reference spectrum.

nonnegative

logical; set TRUE to restrict coefficients to be positive.

Value

a list containing the following members:

coefficients

coefficient matrix

basis

the references object as supplied

fit

the return value of the multivariate call to `stats::lm()` or a list of return values of the outputs of `nnls::nnls()` for each target spectrum.