
Estimate effective doses for grouped dose-response data
Source:R/ec50-estimation.R
estimate_EC50.Rd`estimate_EC50()` fits one dose-response model per isolate, optionally within strata such as year, site, treatment, or fungicide. `ec50_multimodel()` repeats the same workflow for several `drc` model functions and returns model-selection statistics with the estimates.
Usage
estimate_EC50(
formula,
data,
EC_lvl = 50,
isolate_col,
strata_col = NULL,
fct,
interval = c("none", "delta", "fls", "tfls"),
type = c("relative", "absolute"),
quiet = FALSE
)
ec50_multimodel(
formula,
data,
EC_lvl = 50,
isolate_col,
strata_col = NULL,
fct,
interval = c("none", "delta", "fls", "tfls"),
type = c("relative", "absolute"),
quiet = FALSE
)Arguments
- formula
A two-sided formula identifying one numeric response and one numeric dose column, for example `growth ~ dose`.
- data
A data frame containing the numeric response, numeric dose, isolate, and optional stratification columns.
- EC_lvl
Numeric effective-dose level(s) passed to [drc::ED()]. The default estimates EC50.
- isolate_col
Character scalar naming the column that identifies each isolate.
- strata_col
Optional character vector naming columns used to split the data before fitting models.
- fct
A `drc` model function object such as `drc::LL.3()` for `estimate_EC50()`. For `ec50_multimodel()`, provide a list such as `list(drc::LL.3(), drc::LL.4())`.
- interval
Character scalar passed to [drc::ED()]. One of `"none"`, `"delta"`, `"fls"`, or `"tfls"`.
- type
Character scalar passed to [drc::ED()]. One of `"relative"` or `"absolute"`.
- quiet
Logical. If `FALSE`, failed isolate/model fits are reported with a warning.
Value
A data frame with one row per successful estimate. The first columns identify the isolate (`ID`) and strata, followed by columns returned by [drc::ED()]. `ec50_multimodel()` also appends model-selection statistics from [drc::mselect()] and a `model` column. The result keeps its data-frame behavior, but also stores the original data, formula, grouping columns, model functions, and fitted `drc` models so it can be passed directly to [plot_EC50_curves()].
Examples
data(multi_isolate)
sample_data <- subset(
multi_isolate,
isolate == 1 & fungicida == "Fungicide A"
)
estimate_EC50(
growth ~ dose,
data = sample_data,
isolate_col = "isolate",
strata_col = c("field", "fungicida"),
fct = drc::LL.3()
)
#> ID field fungicida Estimate Std..Error
#> 1 1 Organic Fungicide A 0.006072082 0.0005740341
ec50_multimodel(
growth ~ dose,
data = sample_data,
isolate_col = "isolate",
strata_col = c("field", "fungicida"),
fct = list(drc::LL.3(), drc::LL.4())
)
#> ID field fungicida Estimate Std..Error logLik IC
#> 1 1 Organic Fungicide A 0.006072082 0.0005740341 -45.15079 98.30158
#> 11 1 Organic Fungicide A 0.006364103 0.0007031475 -44.69257 99.38515
#> Lack.of.fit Res.var model
#> 1 0.7271292 0.8451681 LL.3
#> 11 0.7370811 0.8498845 LL.4