Fit a Govardovskii visual-pigment template to measured spectral sensitivity.
Source:R/species_perception.R
fit_sensitivity.RdFinds the peak wavelength (\(\lambda_{\max}\)) that minimises the sum of
squared residuals between the Govardovskii (2000) template and the supplied
sensitivity measurements. Uses optimize for an exact
single-parameter search, so the result is a continuous estimate rather than
a grid point.
Arguments
- lambda
Wavelengths at which sensitivity was measured (nm).
- sensitivity
Measured spectral sensitivity. Normalised to \([0, 1]\) internally; need not be pre-normalised.
NAvalues are silently dropped.- chromophore
"A1"(11-cis retinal, default) or"A2"(11-cis 3,4-didehydroretinal).- lambda_max_range
Length-2 numeric vector giving the search interval for \(\lambda_{\max}\) in nm. Default
c(300, 700).
Value
A list with components:
lambda_maxBest-fit peak wavelength (nm).
chromophoreChromophore used.
SSResidual sum of squares at the optimum.
fittedData frame with columns
lambdaandSgiving the template evaluated on the input wavelength grid.
References
Govardovskii VI, Fyhrquist N, Reuter T, Kuzmin DG, Donner K (2000) In search of the visual pigment template. Visual Neuroscience 17:509–528.
Examples
lam <- seq(400, 700, by = 10)
true <- govardovskii_template(lam, lambda_max = 530)$S
noisy <- pmax(0, true + rnorm(length(true), 0, 0.02))
fit <- fit_sensitivity(lam, noisy)
fit$lambda_max # should be close to 530
#> [1] 529.7793