devRateModel {devRate} | R Documentation |
Compute non-linear regression
Description
Determine the nonlinear least-squares estimates of the parameters of a
nonlinear model, on the basis of the nls
function from package
stats
.
Usage
devRateModel(eq, temp, devRate, startValues, dfData = NULL, algo = "GN", ...)
Arguments
eq |
The name of the equation. See |
temp |
The temperature (vector). |
devRate |
The development rate |
startValues |
Starting values for the regression (list). |
dfData |
A data.frame with the temperature in the first column and the development rate in the second column (alternative to the use of temp and devRate). |
algo |
The abbreviated name of the algorithm used for model fitting ( "GN" for Gauss-Newton algorithm, "LM" for Levenberg-Marquardt algorithm; "GN" is the default value). |
... |
Additional arguments for the |
Details
startValues
for equations by Stinner et al. 1974 and Lamb
1992 are composed of two equations: one for the temperatures below the
optimal temperature and another for the temperatures above the optimal
temperature. For these equations, startValues
should be a list
of two lists, where the second element only contain starting estimates not
specified in the first element, e.g., for Stinner et al.:
startValues <- list(list(C = 0.05, k1 = 5, k2 = -0.3), list(Topt = 30))
,
and for Lamb 1992:
startValues <- list(list(Rm = 0.05, Tmax = 35, To = 15), list(T1 = 4))
The temperature should be provided as a vector in argument temp
and
development rate in another vector in argument devRate
. However, it is
possible to use the function with a data.frame containing the temperature in the
first column and the development rate in the sceond column, using the argument
dfData
NULL is returned when an unknown algorithm is entered.
Value
An object of class nls
(except for Stinner et al. 1974 and
Lamb 1992 where the function returns a list of two objects of class
nls
).
Examples
## Example with a linear model (no starting estimates)
myT <- 5:15
myDev <- -0.05 + rnorm(n = length(myT), mean = myT, sd = 1) * 0.01
myNLS <- devRateModel(
eq = campbell_74,
temp = myT,
devRate = myDev)
## Example with a non-linear model (starting estimates)
myT <- seq(from = 0, to = 50, by = 10)
myDev <- c(0.001, 0.008, 0.02, 0.03, 0.018, 0.004)
myNLS <- devRateModel(
eq = stinner_74,
temp = myT,
devRate = myDev,
startValues = list(
list(C = 0.05, k1 = 5, k2 = -0.3),
list(Topt = 30)))
## Example with a data.frame instead of two vectors for temperature and
## development rate
myDF <- data.frame(myT, myDev)
myNLS <- devRateModel(
eq = campbell_74,
dfData = myDF)