Calculate a 3- or 4-parameter monoexponential curve. Model family fit by
analyse_kinetics() with method = "monoexponential", and by
stats::nls() via the self-starting wrapper SSmonoexponential().
Arguments
- t
A numeric vector of the predictor variable (time).
- A
A numeric parameter for the starting baseline of the response variable.
- B
A numeric parameter for the ending asymptote of the response variable.
- tau
A numeric parameter for the time constant (\(\tau\)) of the exponential response, in units of the predictor variable
t.- TD
A numeric parameter for the time delay before the onset of the exponential response, in units of the predictor variable
t. IfNULL(default), a 3-parameter model without time delay is used.
Details
Examples
## create an exponential curve with random noise
set.seed(13)
t <- 1:60
x <- monoexponential(t, A = 10, B = 100, tau = 8, TD = 15) +
rnorm(length(t), 0, 3)
data <- data.frame(t, x)
## 4-parameter fit with the self-starting wrapper
model <- nls(x ~ SSmonoexponential(t, A, B, tau, TD), data = data)
summary(model)
#>
#> Formula: x ~ SSmonoexponential(t, A, B, tau, TD)
#>
#> Parameters:
#> Estimate Std. Error t value Pr(>|t|)
#> A 10.4611 0.7622 13.72 <2e-16 ***
#> B 100.2334 0.7527 133.17 <2e-16 ***
#> tau 8.3128 0.3562 23.34 <2e-16 ***
#> TD 14.8835 0.1898 78.43 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 2.852 on 56 degrees of freedom
#>
#> Number of iterations to convergence: 4
#> Achieved convergence tolerance: 1.182e-06
#>
y <- predict(model, data)
# \donttest{
if (requireNamespace("ggplot2", quietly = TRUE)) {
ggplot2::ggplot(data, ggplot2::aes(t, x)) +
theme_mnirs() +
ggplot2::geom_point() +
ggplot2::geom_line(ggplot2::aes(y = y))
}
# }