View source: R/analyse_monoexponential.R
| monoexponential | R Documentation |
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().
monoexponential(t, A, B, tau, TD = NULL)
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 ( |
TD |
A numeric parameter for the time delay before the onset of the
exponential response, in units of the predictor variable |
3-parameter: A + (B - A) * (1 - exp(-t / tau))
4-parameter: A + (B - A) * (1 - exp(-pmax(t - TD, 0) / tau))
Clamping the shifted time at zero holds the curve flat at the baseline A
until the response onset at t = TD.
The rate constant k is the reciprocal of tau (k = 1 / tau) in
reciprocal units of t (e.g. sec^-1). The mean response time is the
time sum MRT = TD + tau, and the half-response time is
HRT = TD + tau * log(2).
A numeric vector of predicted values the same length as the
predictor variable t.
analyse_kinetics(), SSmonoexponential(),
exponential_drift(), biexponential(), response_time(),
peak_slope()
## 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)
y <- predict(model, data)
if (requireNamespace("ggplot2", quietly = TRUE)) {
ggplot2::ggplot(data, ggplot2::aes(t, x)) +
theme_mnirs() +
ggplot2::geom_point() +
ggplot2::geom_line(ggplot2::aes(y = y))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.