Learn R Programming

devRate (version 0.1.10)

devRateModel: 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, df = NULL, ...)

Arguments

eq

The name of the equation.

temp

The temperature.

devRate

The development rate (days)^-1

startValues

Starting values for the regression.

df

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).

...

Additional arguments for the nls function.

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).

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 df

Examples

Run this code
# NOT RUN {
## 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, df = myDF)
# }

Run the code above in your browser using DataLab