Title: | Robust Non-Linear Regression using AIC Scores |
---|---|
Description: | Non-linear least squares regression with the Levenberg-Marquardt algorithm using multiple starting values for increasing the chance that the minimum found is the global minimum. |
Authors: | Daniel Padfield [aut, cre], Granville Matheson [aut], Francis Windram [aut] |
Maintainer: | Daniel Padfield <[email protected]> |
License: | GPL-3 |
Version: | 2.0.0 |
Built: | 2025-02-02 06:27:07 UTC |
Source: | https://github.com/padpadpadpad/nls.multstart |
A dataset containing example data of rates of photosynthesis and respiration of the phytoplankton Chlorella vulgaris. Instantaneous rates of metabolism were made across a range of assay temperatures to incorporate the entire thermal response of the populations. The dataset is the cleaned version so some datapoints have been omitted.
data("Chlorella_TRC")
data("Chlorella_TRC")
A data frame with 649 rows and 7 variables:
a unique value for each separate curve
the growth temperature that the culture was maintained at before measurements were taken (degrees centigrade)
whether the cultures had been kept for a long time at their growth temperature (adaptation/~100 generations) or a short time (a measure of acclimation/~10 generations)
whether the curve depicts respiration or gross photosynthesis
the assay temperature at which the metabolic rate was measured (degrees centigrade)
the assay temperature in degrees Kelvin
the metabolic rate measured (micro mol O2 micro gram C-1 hr-1)
Daniel Padfield
Padfield, D., Yvon-durocher, G., Buckling, A., Jennings, S. & Yvon-durocher, G. (2015). Rapid evolution of metabolic traits explains thermal adaptation in phytoplankton, Ecology Letters, 19, 133-142.
data("Chlorella_TRC") library(ggplot2) ggplot(Chlorella_TRC) + geom_point(aes(temp, ln.rate, col = process)) + facet_wrap(~ growth.temp + flux)
data("Chlorella_TRC") library(ggplot2) ggplot(Chlorella_TRC) + geom_point(aes(temp, ln.rate, col = process)) + facet_wrap(~ growth.temp + flux)
Finds the best estimated model using non-linear least squares regression using nlsLM(). The best fit is determined using AIC scores.
formula |
a non-linear model formula, with the response on the left of a ~ operator and an expression involving parameters on the right. |
data |
(optional) data.frame, list or environment in which to evaluate
the variables in |
iter |
number of combinations of starting parameters which will be tried
. If a single value is provided, then a shotgun/random-search/lhs approach
will be used to sample starting parameters from a uniform distribution
within the starting parameter bounds. If a vector of the same length as the
number of parameters is provided, then a gridstart approach will be used to
define each combination of that number of equally spaced intervals across
each of the starting parameter bounds respectively. Thus, c(5,5,5) for
three fitted parameters yields 125 model fits. Supplying a vector for
|
start_lower |
lower boundaries for the start parameters. If missing, this will default to -1e+10. |
start_upper |
upper boundaries for the start parameters. If missing, this will default to 1e+10. |
supp_errors |
if |
convergence_count |
The number of counts that the winning model should
be undefeated for before it is declared the winner. This argument defaults
to 100. If specified as |
control |
specific control can be specified using
|
modelweights |
Optional model weights for the nls. If |
lhstype |
Method to use for Latin Hypercube Sampling using |
... |
Extra arguments to pass to |
returns a nls object of the best estimated model fit.
Useful additional arguments for nlsLM
include: na.action = na.omit
, lower/upper = c()
where these
represent upper and lower boundaries for parameter estimates.
Daniel Padfield
Granville Matheson
Francis Windram
nlsLM
for details on additional arguments
to pass to the nlsLM function. lhs
for details of Latin Hypercube Sampling
# load in data data("Chlorella_TRC") Chlorella_TRC_test <- Chlorella_TRC[Chlorella_TRC$curve_id == 1,] # run nls_multstart() # define the Sharpe-Schoolfield equation schoolfield_high <- function(lnc, E, Eh, Th, temp, Tc) { Tc <- 273.15 + Tc k <- 8.62e-5 boltzmann.term <- lnc + log(exp(E/k*(1/Tc - 1/temp))) inactivation.term <- log(1/(1 + exp(Eh/k*(1/Th - 1/temp)))) return(boltzmann.term + inactivation.term) } fits <- nls_multstart(ln.rate ~ schoolfield_high(lnc, E, Eh, Th, temp = K, Tc = 20), data = Chlorella_TRC_test, iter = 500, start_lower = c(lnc=-10, E=0.1, Eh=0.5, Th=285), start_upper = c(lnc=10, E=2, Eh=5, Th=330), lower = c(lnc=-10, E=0, Eh=0, Th=0), supp_errors = 'Y')
# load in data data("Chlorella_TRC") Chlorella_TRC_test <- Chlorella_TRC[Chlorella_TRC$curve_id == 1,] # run nls_multstart() # define the Sharpe-Schoolfield equation schoolfield_high <- function(lnc, E, Eh, Th, temp, Tc) { Tc <- 273.15 + Tc k <- 8.62e-5 boltzmann.term <- lnc + log(exp(E/k*(1/Tc - 1/temp))) inactivation.term <- log(1/(1 + exp(Eh/k*(1/Th - 1/temp)))) return(boltzmann.term + inactivation.term) } fits <- nls_multstart(ln.rate ~ schoolfield_high(lnc, E, Eh, Th, temp = K, Tc = 20), data = Chlorella_TRC_test, iter = 500, start_lower = c(lnc=-10, E=0.1, Eh=0.5, Th=285), start_upper = c(lnc=10, E=2, Eh=5, Th=330), lower = c(lnc=-10, E=0, Eh=0, Th=0), supp_errors = 'Y')