1 #' Two-component error model  2 #'  3 #' Function describing the standard deviation of the measurement error in  4 #' dependence of the measured value \eqn{y}:  5 #'  6 #' \deqn{\sigma = \sqrt{ \sigma_{low}^2 + y^2 * {rsd}_{high}^2}} sigma =  7 #' sqrt(sigma_low^2 + y^2 * rsd_high^2)  8 #'  9 #' This is the error model used for example by Werner et al. (1978). The model  10 #' proposed by Rocke and Lorenzato (1995) can be written in this form as well,  11 #' but assumes approximate lognormal distribution of errors for high values of  12 #' y.  13 #'  14 #' @param y The magnitude of the observed value  15 #' @param sigma_low The asymptotic minimum of the standard deviation for low  16 #' observed values  17 #' @param rsd_high The coefficient describing the increase of the standard  18 #' deviation with the magnitude of the observed value  19 #' @return The standard deviation of the response variable.  20 #' @references Werner, Mario, Brooks, Samuel H., and Knott, Lancaster B. (1978)  21 #' Additive, Multiplicative, and Mixed Analytical Errors. Clinical Chemistry  22 #' 24(11), 1895-1898.  23 #'  24 #' Rocke, David M. and Lorenzato, Stefan (1995) A two-component model for  25 #' measurement error in analytical chemistry. Technometrics 37(2), 176-184.  26 #' @examples  27 #' times <- c(0, 1, 3, 7, 14, 28, 60, 90, 120)  28 #' d_pred <- data.frame(time = times, parent = 100 * exp(- 0.03 * times))  29 #' set.seed(123456)  30 #' d_syn <- add_err(d_pred, function(y) sigma_twocomp(y, 1, 0.07),  31 #' reps = 2, n = 1)[[1]]  32 #' f_nls <- nls(value ~ SSasymp(time, 0, parent_0, lrc), data = d_syn,  33 #' start = list(parent_0 = 100, lrc = -3))  34 #' library(nlme)  35 #' f_gnls <- gnls(value ~ SSasymp(time, 0, parent_0, lrc),  36 #' data = d_syn, na.action = na.omit,  37 #' start = list(parent_0 = 100, lrc = -3))  38 #' if (length(findFunction("varConstProp")) > 0) {  39 #' f_gnls_tc <- update(f_gnls, weights = varConstProp())  40 #' f_gnls_tc_sf <- update(f_gnls_tc, control = list(sigma = 1))  41 #' }  42 #' f_mkin <- mkinfit("SFO", d_syn, error_model = "const", quiet = TRUE)  43 #' f_mkin_tc <- mkinfit("SFO", d_syn, error_model = "tc", quiet = TRUE)  44 #' plot_res(f_mkin_tc, standardized = TRUE)  45 #' AIC(f_nls, f_gnls, f_gnls_tc, f_gnls_tc_sf, f_mkin, f_mkin_tc)  46 #' @export  47 sigma_twocomp <- function(y, sigma_low, rsd_high) {  48 2  sqrt(sigma_low^2 + y^2 * rsd_high^2)  49 } 

Read our documentation on viewing source code .