Computes a model's curve: dense, noise-free values of the dependent variable
across a range of the independent variable, ready to plot with
make_plot(). It calls simulate_data() with no noise. With
conf.int = TRUE it also computes a parameter uncertainty envelope from the
confidence bounds that fit_model() returns.
Usage
make_curve(
model,
params,
x.min,
x.max,
z.values = NULL,
n.samples = 250,
space = "linear",
conf.int = FALSE,
dilution.factor = NULL,
x.range = NULL
)Arguments
- model
The model's code, one of VALID_MODELS, e.g.
"MM"or"CI".- params
A named list of parameter values, as for
simulate_data(). Withconf.int = TRUEit must also hold each parameter's bounds, named<parameter>.lband<parameter>.ub(e.g.Km.lb), as infit_model()$fitted.params.- x.min, x.max
The range of the primary independent variable (
AorP).x.minmust be 0 or more, and less thanx.max.- z.values
For models with an extra independent variable (
I,BorR), a numeric vector of its values. Data is generated for every combination of x and z. The values must be 0 or more (more than 0 forRin"QBK"). Ignored for other models.- n.samples
The number of points along the curve (default 250, smooth enough for most plots).
- space
How the points along the curve are spaced:
"linear"(default),"exponential"(denser at low x),"inverse.exponential"(denser at high x),"dilution.series"or"custom", as described insimulate_data().- conf.int
If
TRUE, also compute the lower and upper envelope curves (see Details). DefaultFALSE.- dilution.factor
For
space = "dilution.series", the factor (more than 1) between successive concentrations, e.g. 2 for a two-fold series.- x.range
For
space = "custom", the x values to use: at least two, all betweenx.minandx.max.
Value
A data frame with the same columns as simulate_data(). With
conf.int = TRUE, each column is repeated with the suffixes .lb and
.ub (e.g. A.lb, V.lb, A.ub, V.ub) for the lower and upper
envelope curves.
Details
The envelope. The lower envelope curve uses, for each parameter,
whichever of its confidence bounds makes the curve lower (e.g. the upper
bound of Km and the lower bound of Vmax), and the upper curve uses the
other bound. For a Hill coefficient n, both bounds are tried and the
lowest and highest curves kept. Bounds of 0 or less are raised to 1e-10. The
envelope shows how far the curve moves when each parameter is at the edge
of its own confidence interval. It is not a confidence band for the curve,
and it can be wider than one, because it ignores the correlation between
the parameters.
See also
make_plot() to plot the curve, fit_model() for fitted
parameters and their bounds.
Examples
curve <- make_curve("MM", list(Km = 0.5, Vmax = 2), x.min = 0, x.max = 5)
head(curve)
#> A V
#> 1 0.00000000 0.00000000
#> 2 0.02008032 0.07722008
#> 3 0.04016064 0.14869888
#> 4 0.06024096 0.21505376
#> 5 0.08032129 0.27681661
#> 6 0.10040161 0.33444816
make_plot("MM", curve.df = curve)
# One curve per inhibitor concentration
make_plot("CI", curve.df = make_curve("CI", list(Km = 0.5, Vmax = 2, Ki = 1),
x.min = 0, x.max = 5, z.values = c(0, 1, 2)))
# The envelope from a fit's confidence intervals
set.seed(1)
mm <- simulate_data("MM", list(Km = 0.5, Vmax = 2), x.min = 0.1, x.max = 5,
n.samples = 8, n.replicates = 3)
fit <- fit_model("MM", mm, start.params = list(Km = 1, Vmax = 1),
get.conf.int = TRUE)
envelope <- make_curve("MM", fit$fitted.params, x.min = 0, x.max = 5,
conf.int = TRUE)
make_plot("MM", data.df = mm, curve.df = envelope, conf.int = TRUE)
