Description Usage Arguments Value Note Author(s) See Also Examples
Finds the best estimated model to each of a set of curves using non-linear least squares regression using nlsLM(). The best fit is determined using AIC scores.
1 2 |
model |
a non-linear model formula, with the response on the left of a ~ operator and an expression involving parameters on the right. |
data |
a data frame containing an column to differentiate between curves and the response and predictor variables. |
tries |
number of combinations of starting parameters that are tried on each curve. |
id_col |
the column name that identifies each curve that is to be fitted in "". |
param_bds |
lower and upper boundaries for the start parameters. If missing these default to +/- 1e+09. Need to specified as a vector as : c(lower bound param 1, upper bound param 1, lower bound param 2, upper bound param 2 etc) |
r2 |
whether or not the quasi rsquared value is calculated and returned.
This defaults to no, to include the r2 values use |
supp_errors |
if |
AICc |
whether or not the small sample AIC should be used. Defaults to
|
control |
specific control can be specified using |
return_preds |
whether predictions of each individual model fit are wanted alongside the parameters or. Defaults to yes ('Y'). Add 'N' to change to no. |
... |
Extra arguments to pass to |
returns a list of class nlsLoop
. Notable elements within the list are $params
and $predictions
that give the best fit parameters and predictions based on these parameters for each individual 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
quasi_rsq_nls
for details on the calculation of r squared values for non linear models.
nlsLM
for details on additional arguments to pass to the nlsLM function.
AICc
for application of AICc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # load in data
data("Chlorella_TRC")
Chlorella_TRC_test <- Chlorella_TRC[Chlorella_TRC$curve_id %in% c(1:10),]
# run nlsLoop()
# 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 <- nlsLoop(ln.rate ~ schoolfield_high(lnc, E, Eh, Th, temp = K, Tc = 20),
data = Chlorella_TRC_test,
tries = 500,
id_col = 'curve_id',
param_bds = c(-10, 10, 0.1, 2, 0.5, 5, 285, 330),
lower = c(lnc=-10, E=0, Eh=0, Th=0))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.