| Title: | Perform Pharmacokinetic Non-Compartmental Analysis |
|---|---|
| Description: | Compute standard Non-Compartmental Analysis (NCA) parameters for typical pharmacokinetic analyses and summarize them. |
| Authors: | Bill Denney [aut, cre] (ORCID: <https://orcid.org/0000-0002-5759-428X>), Clare Buckeridge [aut], Gerardo Jose Rodriguez [aut] (ORCID: <https://orcid.org/0000-0003-1413-0060>), Sridhar Duvvuri [ctb], Natalie Sang [ctb] |
| Maintainer: | Bill Denney <[email protected]> |
| License: | AGPL-3 |
| Version: | 0.12.1.9002 |
| Built: | 2026-10-09 16:33:25 UTC |
| Source: | https://github.com/humanpred/pknca |
Add columns for calculations within PKNCA intervals
add.interval.col( name, FUN, values = c(FALSE, TRUE), unit_type, pretty_name, depends = NULL, desc = "", sparse = FALSE, formalsmap = list(), FUN_sparse = NA_character_, formalsmap_sparse = list(), datatype = c("interval", "individual", "population"), pptestcd_cdisc = NULL, pptest_cdisc = NULL, formula = NULL, formula_note = NULL, tier = "uncommon", selection = NULL )add.interval.col( name, FUN, values = c(FALSE, TRUE), unit_type, pretty_name, depends = NULL, desc = "", sparse = FALSE, formalsmap = list(), FUN_sparse = NA_character_, formalsmap_sparse = list(), datatype = c("interval", "individual", "population"), pptestcd_cdisc = NULL, pptest_cdisc = NULL, formula = NULL, formula_note = NULL, tier = "uncommon", selection = NULL )
name |
The column name as a non-empty character string (length 1,
may not be |
FUN |
The function to run (as a character string) or |
values |
Valid values for the column: either a function used to
coerce/validate values (e.g. |
unit_type |
The type of units to use for assigning and converting units. Must be one of the pre-defined unit types (see Details). This argument is required and has no default; omitting it raises an error. |
pretty_name |
The name of the parameter to use for printing in summary tables with units. (If an analysis does not include units, then the normal name is used.) |
depends |
Character vector of columns that must be run before this column. |
desc |
A human-readable description of the parameter. SDTM requires <=40 characters; a longer description is accepted with a warning. |
sparse |
Retired. |
formalsmap |
A named list mapping parameter names in the function call
to NCA parameter names. See the details for information on use of
|
FUN_sparse |
The function to run (as a character string) when the data
are sparse PK, or |
formalsmap_sparse |
The |
datatype |
The data type used for the calculation. The default is
|
pptestcd_cdisc |
The CDISC PPTESTCD code for this parameter. Can be a
character string for simple mappings, a named list for route-dependent
mappings with a |
pptest_cdisc |
The CDISC PPTEST name for this parameter. Can be a
character string or a named list (same structure as |
formula |
Character value providing a LaTeX expression for how the parameter is calculated. Optional and used only for documentation. |
formula_note |
Character value providing additional context about the formula (e.g. assumptions or method details). Displayed alongside the formula in documentation tables. |
tier |
How commonly the parameter is reported: |
selection |
A named list declaring what cannot be derived about where
the parameter applies. Every element is optional, and the default of
|
FUN_sparse gives a parameter a second calculation function for
sparse PK. With sparse data, a parameter that has one is calculated with it
– from the pooled individual samples, and with formalsmap_sparse in place
of formalsmap – and its result is reported as a sparse result. A
parameter with no FUN_sparse falls back to FUN applied to the
arithmetic-mean profile, which is what sparse data have always done. A
sparse estimator names its concentration inputs conc/time the way a dense
one does; those draw from the pooled samples rather than the mean profile.
The estimators PKNCA ships are linear-trapezoidal only, so auc.method does
not apply to them.
The formalsmap argument enables mapping some alternate formal
argument names to parameters. It is used to generalize functions that may
use multiple similar arguments (such as the variants of mean residence time).
The names of the list should correspond to function formal parameter names
and the values should be one of the following:
For the current interval:
The value of the parameter calculated for the current interval.
Concentration measurements for the current interval.
Times associated with concentration measurements for the current interval (values start at 0 at the beginning of the current interval).
Volume associated with concentration measurements for the current interval (typically applies for excretion parameters like urine).
Durations associated with concentration measurements for the current interval.
Dose amounts assocuated with the current interval.
Time of dose start associated with the current interval (values start at 0 at the beginning of the current interval).
Duration of dose (typically infusion duration) for doses in the current interval.
Route of dosing for the current interval.
Time of interval start.
Time of interval end.
PKNCA.options governing calculations.
For the current group:
Concentration measurements for the current group.
Times associated with concentration measurements for the current group (values start at 0 at the beginning of the current interval).
Volume associated with concentration measurements for the current interval (typically applies for excretion parameters like urine).
Durations assocuated with concentration measurements for the current group.
Dose amounts assocuated with the current group.
Time of dose start associated with the current group (values start at 0 at the beginning of the current interval).
Duration of dose (typically infusion duration) for doses in the current group.
Route of dosing for the current group.
For sparse PK (NULL with dense PK, so a parameter naming one of
these is only calculable with a sparse PKNCAconc):
The pooled individual concentration measurements for the current interval ("conc" is the arithmetic-mean profile built from them).
Times associated with the pooled individual concentration measurements for the current interval (values start at 0 at the beginning of the current interval).
The pooled individual concentration measurements for the current group.
Times associated with the pooled individual concentration measurements for the current group.
Subject identifiers for the pooled individual concentration measurements for the current interval.
Constants:
base::I()
The value itself, passed to the
function unchanged. Use this for an argument that selects a variant of
a shared calculation function (for example, auc.type = I("AUCall"))
rather than naming a data source or another parameter.
For the reference interval:
pknca_ref()
The value of that NCA
parameter calculated in the reference interval, which is the interval
named by the <name>_ref column of the interval specification. A
parameter with any such argument is a secondary parameter; see the
vignette "Secondary parameters".
NULL (Calling this function has a side effect of changing the available intervals for calculations)
Other Interval specifications:
check.interval.specification(),
choose.auc.intervals(),
get.interval.cols(),
get.parameter.deps(),
interval_add_impute(),
interval_add_param(),
interval_add_secondary(),
pknca_cdisc_codes(),
pknca_check_parameter_classification(),
pknca_concepts(),
pknca_interval_table(),
pknca_match_route(),
pknca_parameter_table(),
pknca_presets(),
pknca_ref()
## Not run: add.interval.col("cmax", FUN="pk.calc.cmax", values=c(FALSE, TRUE), unit_type="conc", pretty_name="Cmax", desc="Maximum observed concentration") add.interval.col("cmax.dn", FUN="pk.calc.dn", values=c(FALSE, TRUE), unit_type="conc_dosenorm", pretty_name="Cmax (dose-normalized)", desc="Maximum observed concentration, dose normalized", formalsmap=list(parameter="cmax"), depends="cmax") ## End(Not run)## Not run: add.interval.col("cmax", FUN="pk.calc.cmax", values=c(FALSE, TRUE), unit_type="conc", pretty_name="Cmax", desc="Maximum observed concentration") add.interval.col("cmax.dn", FUN="pk.calc.dn", values=c(FALSE, TRUE), unit_type="conc_dosenorm", pretty_name="Cmax (dose-normalized)", desc="Maximum observed concentration, dose normalized", formalsmap=list(parameter="cmax"), depends="cmax") ## End(Not run)
Add a hash and associated information to enable checking object provenance.
addProvenance(object, replace = FALSE)addProvenance(object, replace = FALSE)
object |
The object to add provenance |
replace |
Replace provenance if the object already has a provenance
attribute. (If the object already has provenance and |
The object with provenance as an added item
Calculate the adjusted r-squared value
adj.r.squared(r.sq, n)adj.r.squared(r.sq, n)
r.sq |
The r-squared value |
n |
The number of points |
The numeric adjusted r-squared value
Other Half-life and elimination:
pk.calc.aucpext(),
pk.calc.half.life(),
pk.calc.thalf.eff()
A calculation is sparse when only sparse data can produce it, which is a
property of the registration rather than a flag; see add.interval.col().
any_sparse_dense_in_interval(interval, sparse)any_sparse_dense_in_interval(interval, sparse)
interval |
An interval specification |
sparse |
Are the concentration-time data sparse PK (commonly used in small nonclinical species or with terminal or difficult sampling) or dense PK (commonly used in clinical studies or larger nonclinical species)? |
A logical value indicating if the interval requests any sparse (if
sparse=TRUE) or dense (if sparse=FALSE) calculations.
Convert an object into a PKNCAconc object
as_PKNCAconc(x, ...) as_PKNCAdose(x, ...) as_PKNCAdata(x, ...) as_PKNCAresults(x, ...)as_PKNCAconc(x, ...) as_PKNCAdose(x, ...) as_PKNCAdata(x, ...) as_PKNCAresults(x, ...)
x |
The object to convert |
... |
Passed to subsequent methods |
A converted object
as_PKNCAdose(): Convert an object into a PKNCAdose object
as_PKNCAdata(): Convert an object into a PKNCAdata object
as_PKNCAresults(): Convert an object into a PKNCAresults object
Generate a sparse_pk object
as_sparse_pk(conc, time, subject)as_sparse_pk(conc, time, subject)
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
subject |
Subject identifiers (may be any class; may not be null). A
missing subject marks an imputed concentration (such as the zero that the
|
A sparse_pk object which is a list of lists. The inner lists have elements named: "time", The time of measurement; "conc", The concentration measured; "subject", The subject identifiers; "imputed", Whether the concentration at that time is imputed (known). The object will usually be modified by future functions to add more named elements to the inner list.
Other Sparse Methods:
pk.calc.aucinf.obs_sparse(),
pk.calc.aucivlast_sparse(),
pk.calc.auclast_sparse(),
pk.calc.sparse_auc(),
pk.calc.sparse_aumc(),
sparse_auc_weight_linear(),
sparse_bootstrap(),
sparse_mean(),
summary.PKNCAresults_sparse_bootstrap()
Extract the parameter results from a PKNCAresults and return them as a data.frame.
## S3 method for class 'PKNCAresults' as.data.frame( x, ..., out_format = c("long", "wide", "cdisc"), filter_requested = FALSE, filter_excluded = FALSE, grpid_cols = NULL, grpid_numeric = NULL, out.format = deprecated() )## S3 method for class 'PKNCAresults' as.data.frame( x, ..., out_format = c("long", "wide", "cdisc"), filter_requested = FALSE, filter_excluded = FALSE, grpid_cols = NULL, grpid_numeric = NULL, out.format = deprecated() )
x |
The object to extract results from |
... |
Ignored (for compatibility with generic |
out_format |
Should the output be 'long' (default), 'wide', or 'cdisc'?
When 'cdisc', the original PKNCA parameter name is kept in a new
Each row also gets its time point reference, as SDTMIG 3.4 defines it:
PPSTINT and PPENINT give the interval start and end as ISO 8601
durations relative to the reference named in PPTPTREF, and PPRFTDTC gives
that reference's date-time. The reference is the dose that starts the
interval: the last included dose at or before the interval start for
that subject and group (PPTPTREF PPGRPID, the record group identifier, is built from the grouping columns
named in |
filter_requested |
Only return rows with parameters that were specifically requested? |
filter_excluded |
Should excluded values be removed? |
grpid_cols |
For |
grpid_numeric |
For |
out.format |
Deprecated in favor of |
A data.frame (or usually a tibble) of results
Assert that a value is a valid AUC method
assert_aucmethod(method = c("lin up/log down", "linear", "lin-log"))assert_aucmethod(method = c("lin up/log down", "linear", "lin-log"))
method |
The method for integration (one of 'lin up/log down', 'lin-log', or 'linear') |
method or an informative error
If the concentrations or times are invalid, will provide an error. Reasons for being invalid are
time is not a number
conc is not a number
Any time value is NA
time is not monotonically increasing
conc and time are not the same length
assert_conc(conc, any_missing_conc = TRUE) assert_time(time, sorted_time = TRUE) assert_conc_time(conc, time, any_missing_conc = TRUE, sorted_time = TRUE)assert_conc(conc, any_missing_conc = TRUE) assert_time(time, sorted_time = TRUE) assert_conc_time(conc, time, any_missing_conc = TRUE, sorted_time = TRUE)
conc |
Measured concentrations |
any_missing_conc |
Are any concentration values allowed to be |
time |
Time of the measurement of the concentrations |
sorted_time |
Must the time be unique and monotonically increasing? |
Some cases may generate warnings but allow the data to proceed.
A negative concentration is often but not always an error; it will generate a warning.
conc or give an informative error
time or give an informative error
NULL, invisibly, when the data are valid; otherwise an
informative error
assert_conc_time(conc = c(0, 2, 1), time = 0:2) # Unsorted times are allowed when `sorted_time = FALSE` assert_conc_time(conc = c(0, 2, 1), time = c(2, 0, 1), sorted_time = FALSE)assert_conc_time(conc = c(0, 2, 1), time = 0:2) # Unsorted times are allowed when `sorted_time = FALSE` assert_conc_time(conc = c(0, 2, 1), time = c(2, 0, 1), sorted_time = FALSE)
Assert that a value is a dosing interval
assert_dosetau(tau)assert_dosetau(tau)
tau |
The dosing interval |
tau or an informative error
The specification is resolved the way PKNCAdata() and pk.nca() resolve
it: the name of a column in intervals, NA to use the "impute" column
of intervals when there is one, or otherwise a string of imputation
methods. Every method named must exist.
assert_impute_method(impute, intervals = data.frame())assert_impute_method(impute, intervals = data.frame())
impute |
The imputation specification (a character scalar or |
intervals |
The intervals data.frame (if the specification may name one of its columns) |
The resolved imputation strings (one per interval when read from a column), invisibly, or an error
PKNCA_impute_fun_list(), PKNCA_impute_method
Other Imputation:
PKNCA_impute_fun_list(),
PKNCA_impute_method,
get_impute_column(),
get_impute_method(),
pknca_impute_methods()
assert_impute_method("start_predose,start_conc0") assert_impute_method( "method", intervals = data.frame(start = 0, end = 24, method = "start_conc0") ) try(assert_impute_method("start_misspelled"))assert_impute_method("start_predose,start_conc0") assert_impute_method( "method", intervals = data.frame(start = 0, end = 24, method = "start_conc0") ) try(assert_impute_method("start_misspelled"))
Verifies that an interval definition is valid for a PKNCAdata object.
Valid means that intervals are a data.frame (or data.frame-like object),
that the column names are either the groupings of the PKNCAconc part of
the PKNCAdata object or that they are one of the NCA parameters allowed
(i.e. names(get.interval.cols())).
The column that the impute setting of the PKNCAdata object names (see
get_impute_method()) is also allowed, and it must be a character column,
or a pknca_error_interval_impute_not_character error is raised.
An interval_id identifies one interval: rows that share it may differ
only in the parameters they request (and impute), not in start, end,
or the groups, or a pknca_error_secondary_id_conflict error is raised.
It will return the intervals argument unchanged, or it will raise an error.
assert_intervals(intervals, data)assert_intervals(intervals, data)
intervals |
Proposed intervals |
data |
PKNCAdata object |
The intervals argument unchanged, or it will raise an error.
Assert that an interval is accurately defined as an interval, and return the interval
assert_intervaltime_single(interval = NULL, start = NULL, end = NULL)assert_intervaltime_single(interval = NULL, start = NULL, end = NULL)
interval |
Numeric vector of two numbers for the start and end time of integration |
start |
The start time of the interval |
end |
The end time of the interval |
interval (or c(start, end))
Assert that a lambda.z value is valid
assert_lambdaz( lambda.z, any.missing = TRUE, .var.name = checkmate::vname(lambda.z) )assert_lambdaz( lambda.z, any.missing = TRUE, .var.name = checkmate::vname(lambda.z) )
lambda.z |
The elimination rate (in units of inverse time) for extrapolation |
any.missing |
[ |
.var.name |
[ |
lambda.z or an informative error
Confirm that a value is greater than another value
assert_number_between( x, ..., na.ok = FALSE, len = 1, .var.name = checkmate::vname(x) )assert_number_between( x, ..., na.ok = FALSE, len = 1, .var.name = checkmate::vname(x) )
x |
[ |
... |
Passed to |
na.ok |
[ |
len |
Ignored (must be 1) |
.var.name |
[ |
x or an informative error
Confirm that a value is greater than another value
assert_numeric_between( x, any.missing = FALSE, null.ok = FALSE, lower_eq = -Inf, lower = -Inf, upper = Inf, upper_eq = Inf, ..., .var.name = checkmate::vname(x) )assert_numeric_between( x, any.missing = FALSE, null.ok = FALSE, lower_eq = -Inf, lower = -Inf, upper = Inf, upper_eq = Inf, ..., .var.name = checkmate::vname(x) )
x |
[ |
any.missing |
[ |
null.ok |
[ |
lower_eq, upper_eq
|
Values where equality is not allowed |
lower |
[ |
upper |
[ |
... |
Passed to |
.var.name |
[ |
x
Assert that a character vector only contains PKNCA parameter names
assert_param_name(param)assert_param_name(param)
param |
A vector of parameter names to check |
param or give an informative error
Assert that an object is a PKNCAdata object
assert_PKNCAdata(object) assert_PKNCAresults(object) assert_PKNCAconc(object) assert_PKNCAdose(object)assert_PKNCAdata(object) assert_PKNCAresults(object) assert_PKNCAconc(object) assert_PKNCAdose(object)
object |
The PKNCAdose object |
The object
assert_PKNCAresults(): Assert that an object is a PKNCAresults object
assert_PKNCAconc(): Assert that an object is a PKNCAconc object
assert_PKNCAdose(): Assert that an object is a PKNCAdose object
Assert that a value may either be a column name in the data (first) or a single unit value (second)
assert_unit_col(unit, data) assert_unit_value(unit) assert_unit(unit, data)assert_unit_col(unit, data) assert_unit_value(unit) assert_unit(unit, data)
unit |
The column name or unit value |
data |
The data.frame that contains a column named |
unit with an attribute of "unit_type" that is either "column" or
"value", or NULL if is.null(unit)
assert_unit_col(): Assert that a column name contains a character string
(that could be a unit specification)
assert_unit_value(): Assert that a value may be a single unit
The function does not verify that it is a real unit like "ng/mL" only that it is a single character string.
Support function for AUC integration
auc_integrate( conc, time, clast, tlast, lambda.z, interval_method, fun_linear, fun_log, fun_inf )auc_integrate( conc, time, clast, tlast, lambda.z, interval_method, fun_linear, fun_log, fun_inf )
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
clast |
The last concentration above the limit of quantification |
tlast |
Time of last concentration above the limit of quantification (will be calculated, if not provided) |
lambda.z |
The elimination rate (in units of inverse time) for extrapolation |
interval_method |
The method for integrating each interval of |
fun_linear |
The function to use for integration of the linear part of the curve (not required for AUC or AUMC functions) |
fun_log |
The function to use for integration of the logarithmic part of the curve (if log integration is used; not required for AUC or AUMC functions) |
fun_inf |
The function to use for extrapolation from the final measurement to infinite time (not required for AUC or AUMC functions). |
be_assess() performs a complete bioequivalence (BE) assessment of one or
more noncompartmental endpoints against a regulatory framework, including
reference scaling and the pass/fail decision. It accepts the results of
pk.nca() directly (a PKNCAresults object) or a tidy long data.frame, so
the same workflow that produces NCA parameters flows into the regulatory
decision. It is a thin wrapper over be_fit_models() that adds the
be_assess class and its print/summary methods.
be_assess(object, ...) ## Default S3 method: be_assess( object, reference_col, reference_value, endpoints = c("cmax", "aucinf.obs", "aucinf.pred", "auclast"), regulator = "ABE", model_type = NULL, alpha = 0.1, subject = NULL, sequence = NULL, period = NULL, design = NULL, covariates = NULL, heteroscedastic = FALSE, ... ) ## S3 method for class 'PKNCAresults_sparse_bootstrap' be_assess( object, reference_col, reference_value, endpoints = c("cmax", "aucinf.obs", "aucinf.pred", "auclast"), regulator = "ABE", model_type = NULL, alpha = 0.1, subject = NULL, sequence = NULL, period = NULL, design = NULL, covariates = NULL, heteroscedastic = FALSE, ... )be_assess(object, ...) ## Default S3 method: be_assess( object, reference_col, reference_value, endpoints = c("cmax", "aucinf.obs", "aucinf.pred", "auclast"), regulator = "ABE", model_type = NULL, alpha = 0.1, subject = NULL, sequence = NULL, period = NULL, design = NULL, covariates = NULL, heteroscedastic = FALSE, ... ) ## S3 method for class 'PKNCAresults_sparse_bootstrap' be_assess( object, reference_col, reference_value, endpoints = c("cmax", "aucinf.obs", "aucinf.pred", "auclast"), regulator = "ABE", model_type = NULL, alpha = 0.1, subject = NULL, sequence = NULL, period = NULL, design = NULL, covariates = NULL, heteroscedastic = FALSE, ... )
object |
A |
... |
Arguments passed to the methods |
reference_col |
The column identifying the formulation/treatment. |
reference_value |
The value of |
endpoints |
Character vector of NCA parameters (matched against
|
regulator |
The regulatory framework (see |
model_type |
The model for the average-BE point estimate, one of
|
alpha |
The significance level; the confidence interval has level
|
subject, sequence, period
|
Column names for the subject, randomization
sequence, and period. When |
design |
An optional |
covariates |
An optional character vector of column names added to
every model as additive fixed effects (numeric columns as linear terms,
character or factor columns as factors). They must not be missing in any
analyzed row. For a |
heteroscedastic |
Logical. When |
The model type is selected automatically from the design and the regulator.
By design, a parallel study (one measurement per subject) uses a fixed-effects
ANOVA ("anova"), while a crossover or replicate study (repeated measures per
subject) uses the mixed model ("lmer") for the geometric mean ratio and its
confidence interval. The FDA reference-scaled frameworks (FDA RSABE, NTID,
HVNTID) always use intra-subject contrasts ("isc"), as the guidances
specify, regardless of design. Pass model_type to override ("lmer",
"anova", "isc", "nlme", or "gls"). Within-subject variability uses
the regulatory ANOVA estimator for the "lmer"/"anova"/"isc" paths and
the treatment-specific mixed-model estimator for "nlme".
With heteroscedastic = TRUE the residual variance is estimated separately
for each treatment: a crossover or replicate study uses nlme::lme() with
varIdent(~ 1 | treatment) ("nlme"), and a parallel study uses
nlme::gls() with the same variance structure ("gls"). lme4::lmer()
cannot estimate treatment-specific residual variances (its weights are
fixed prior weights), so heteroscedastic = TRUE with model_type = "lmer"
is an error. Without reference scaling, "nlme" accepts non-replicated
designs and several test formulations; with reference scaling it needs a
fully replicated design and one test formulation, because the
per-formulation variances are then used as the within-subject variances.
regulator = "descriptive" estimates the geometric means, their ratio, and
its confidence interval exactly as for "ABE" but applies no acceptance
limits and reports no pass/fail, for comparisons such as food effect and
drug-drug interaction studies.
For the results of a sparse bootstrap (Shen and Machado 2017; see
sparse_bootstrap()), there is one estimate per treatment, from the sparse
data, rather than one per subject. The ratio of the test and reference
estimates is the point estimate, and its confidence interval is the
percentile interval of the ratios of the bootstrap replicates (model_type = "bootstrap"). The gm_* columns hold the estimates of each treatment with
their percentile intervals. A parallel design resamples the treatments
independently; for a crossover, give the treatment column as paired to
sparse_bootstrap(). There is no within-subject variance, so only the
"ABE" and "descriptive" frameworks apply, and the results may have no
groups other than reference_col (filter them first).
An object of class be_assess (a data.frame), ordered by endpoint
(in the order requested) then by test formulation (reference-first), with
one row per endpoint and test formulation and the columns endpoint,
test, n, design, units (the endpoint's measurement units; the column
is omitted with a warning when units are not provided), the reference and
test geometric means with their 90% confidence intervals on the measurement
scale (gm_reference, gm_reference_lower, gm_reference_upper, gm_test,
gm_test_lower, gm_test_upper), gmr_percent, ci_lower, ci_upper,
cvwr_percent, cvwt_percent, swr, limit_lower, limit_upper,
criterion, regulator, model_type, and pass. limit_* are NA for
the RSABE criterion and criterion is NA for the limit-based frameworks.
For regulator = "descriptive" the limit_lower, limit_upper,
criterion, and pass columns are omitted. A caption attribute
documents the model and the decision rule, or states that no regulatory
decision was applied.
be_assess(PKNCAresults_sparse_bootstrap): Bioequivalence from the percentile intervals of a
sparse bootstrap (Shen and Machado 2017)
Shen M, Machado SG. Bioequivalence evaluation of sparse sampling pharmacokinetics data using bootstrap resampling method. Journal of Biopharmaceutical Statistics. 2017;27(2):257-264. doi:10.1080/10543406.2016.1265543
be_compare() to assess one dataset under several frameworks,
be_within_var(), and be_regulator().
Other Bioequivalence:
be_compare(),
be_dataset(),
be_design(),
be_expand_limits(),
be_extract_param(),
be_fit_model_single(),
be_fit_models(),
be_regulator(),
be_table(),
be_within_var()
# A replicate-design crossover in long (PPTESTCD/PPORRES) format set.seed(1) nsub <- 24 seqs <- rep(c("TRTR", "RTRT"), length.out = nsub) b <- stats::rnorm(nsub, sd = 0.4) d <- do.call(rbind, lapply(seq_len(nsub), function(i) { trt <- strsplit(seqs[i], "")[[1]] data.frame( subject = i, sequence = seqs[i], period = seq_along(trt), treatment = trt, PPTESTCD = "auclast", PPORRES = exp(log(100) + ifelse(trt == "T", 0.04, 0) + b[i] + stats::rnorm(length(trt), sd = 0.45)) ) })) be_assess(d, reference_col = "treatment", reference_value = "R", endpoints = "auclast", regulator = "EMA")# A replicate-design crossover in long (PPTESTCD/PPORRES) format set.seed(1) nsub <- 24 seqs <- rep(c("TRTR", "RTRT"), length.out = nsub) b <- stats::rnorm(nsub, sd = 0.4) d <- do.call(rbind, lapply(seq_len(nsub), function(i) { trt <- strsplit(seqs[i], "")[[1]] data.frame( subject = i, sequence = seqs[i], period = seq_along(trt), treatment = trt, PPTESTCD = "auclast", PPORRES = exp(log(100) + ifelse(trt == "T", 0.04, 0) + b[i] + stats::rnorm(length(trt), sd = 0.45)) ) })) be_assess(d, reference_col = "treatment", reference_value = "R", endpoints = "auclast", regulator = "EMA")
be_compare() runs be_assess() under several regulatory frameworks and
stacks the results, so the same study can be judged side by side under the
different reference-scaling rules. Frameworks that the design does not
support (for example NTID on a partial replicate) are skipped with a warning.
Rows for the "descriptive" framework have NA in the decision columns.
be_compare( object, reference_col, reference_value, endpoints = c("cmax", "aucinf.obs", "aucinf.pred", "auclast"), regulators = c("ABE", "EMA", "HC", "GCC", "FDA"), model_type = NULL, alpha = 0.1, subject = NULL, sequence = NULL, period = NULL, design = NULL, covariates = NULL, heteroscedastic = FALSE )be_compare( object, reference_col, reference_value, endpoints = c("cmax", "aucinf.obs", "aucinf.pred", "auclast"), regulators = c("ABE", "EMA", "HC", "GCC", "FDA"), model_type = NULL, alpha = 0.1, subject = NULL, sequence = NULL, period = NULL, design = NULL, covariates = NULL, heteroscedastic = FALSE )
object |
A |
reference_col |
The column identifying the formulation/treatment. |
reference_value |
The value of |
endpoints |
Character vector of NCA parameters (matched against
|
regulators |
A character vector of regulatory frameworks to compare (see
|
model_type |
The model for the average-BE point estimate, one of
|
alpha |
The significance level; the confidence interval has level
|
subject, sequence, period
|
Column names for the subject, randomization
sequence, and period. When |
design |
An optional |
covariates |
An optional character vector of column names added to
every model as additive fixed effects (numeric columns as linear terms,
character or factor columns as factors). They must not be missing in any
analyzed row. For a |
heteroscedastic |
Logical. When |
An object of class be_compare (a data.frame) with the be_assess()
columns for every endpoint, test formulation, and regulator.
Other Bioequivalence:
be_assess(),
be_dataset(),
be_design(),
be_expand_limits(),
be_extract_param(),
be_fit_model_single(),
be_fit_models(),
be_regulator(),
be_table(),
be_within_var()
set.seed(1) nsub <- 24 seqs <- rep(c("TRTR", "RTRT"), length.out = nsub) b <- stats::rnorm(nsub, sd = 0.4) d <- do.call(rbind, lapply(seq_len(nsub), function(i) { trt <- strsplit(seqs[i], "")[[1]] data.frame( subject = i, sequence = seqs[i], period = seq_along(trt), treatment = trt, PPTESTCD = "auclast", PPORRES = exp(log(100) + ifelse(trt == "T", 0.04, 0) + b[i] + stats::rnorm(length(trt), sd = 0.45)) ) })) be_compare(d, reference_col = "treatment", reference_value = "R", endpoints = "auclast", regulators = c("EMA", "HC", "GCC", "FDA"))set.seed(1) nsub <- 24 seqs <- rep(c("TRTR", "RTRT"), length.out = nsub) b <- stats::rnorm(nsub, sd = 0.4) d <- do.call(rbind, lapply(seq_len(nsub), function(i) { trt <- strsplit(seqs[i], "")[[1]] data.frame( subject = i, sequence = seqs[i], period = seq_along(trt), treatment = trt, PPTESTCD = "auclast", PPORRES = exp(log(100) + ifelse(trt == "T", 0.04, 0) + b[i] + stats::rnorm(length(trt), sd = 0.45)) ) })) be_compare(d, reference_col = "treatment", reference_value = "R", endpoints = "auclast", regulators = c("EMA", "HC", "GCC", "FDA"))
be_dataset() prepares a noncompartmental result for bioequivalence
calculation: it accepts a PKNCAresults object or a tidy long data.frame,
resolves the value column, drops excluded/invalid rows, detects the
subject/sequence/period columns, validates the reference, and sets the
reference formulation as the first factor level. It standardizes the
modeling columns (.subject, .sequence, .period, .trt, .logval) used
by the downstream fitters.
be_dataset(object, ...) ## Default S3 method: be_dataset( object, reference_col, reference_value, endpoints = c("cmax", "aucinf.obs", "aucinf.pred", "auclast"), subject = NULL, sequence = NULL, period = NULL, covariates = NULL, ... ) ## S3 method for class 'PKNCAresults_sparse_bootstrap' be_dataset( object, reference_col, reference_value, endpoints = c("cmax", "aucinf.obs", "aucinf.pred", "auclast"), subject = NULL, sequence = NULL, period = NULL, covariates = NULL, ... )be_dataset(object, ...) ## Default S3 method: be_dataset( object, reference_col, reference_value, endpoints = c("cmax", "aucinf.obs", "aucinf.pred", "auclast"), subject = NULL, sequence = NULL, period = NULL, covariates = NULL, ... ) ## S3 method for class 'PKNCAresults_sparse_bootstrap' be_dataset( object, reference_col, reference_value, endpoints = c("cmax", "aucinf.obs", "aucinf.pred", "auclast"), subject = NULL, sequence = NULL, period = NULL, covariates = NULL, ... )
object |
A |
... |
Arguments passed to the methods |
reference_col |
The column identifying the formulation/treatment. |
reference_value |
The value of |
endpoints |
Character vector of NCA parameters (matched against
|
subject, sequence, period
|
Column names for the subject, randomization
sequence, and period. When |
covariates |
An optional character vector of column names added to
every model as additive fixed effects (numeric columns as linear terms,
character or factor columns as factors). They must not be missing in any
analyzed row. For a |
The endpoint value is taken from the PPSTRES column when present, otherwise
PPORRES. The measurement units are read from the matching units column –
PPSTRESU for PPSTRES, or PPORRESU for PPORRES – which a PKNCAresults
object provides automatically; a plain data.frame supplies units the same way
by including the corresponding PPSTRESU/PPORRESU column. When no units
column is present, units are unavailable and the units column is omitted
from the assessment table.
Each covariate is copied to a standardized column named .cov_<name>
(character columns become factors). A covariate may not be one of the
subject, sequence, period, treatment, or value columns, and it may not be
missing in any row that is analyzed.
An object of class be_dataset: a list with data (the
standardized long frame, including a .units column and one .cov_<name>
column per covariate), columns (the resolved column names, including
units and covariates), reference_value, test_levels, and
endpoints (those present). For the results of a sparse bootstrap (see
sparse_bootstrap()), data has one row per bootstrap replicate, group,
and endpoint instead of one per subject and period.
be_dataset(PKNCAresults_sparse_bootstrap): The replicates of a sparse bootstrap, one row per
replicate, treatment, and endpoint
Other Bioequivalence:
be_assess(),
be_compare(),
be_design(),
be_expand_limits(),
be_extract_param(),
be_fit_model_single(),
be_fit_models(),
be_regulator(),
be_table(),
be_within_var()
be_design() inspects the treatment-by-period pattern of a crossover study
and reports the design type, the replication of the reference and test
formulations, and which regulatory frameworks are feasible. Reference
scaling (EMA/HC/GCC/FDA) requires the reference to be replicated; the narrow
therapeutic index frameworks additionally require the test to be replicated.
be_design(data, subject, sequence, period, treatment, reference_value)be_design(data, subject, sequence, period, treatment, reference_value)
data |
A long data.frame with one row per concentration-derived observation (subject, period, treatment). |
subject, sequence, period, treatment
|
Column names (length-1 character)
identifying the subject, randomization sequence, period, and treatment.
|
reference_value |
The value of |
An object of class be_design: a list with elements design (one
of "parallel", "2x2x2", "full_replicate", "partial_replicate",
"other"),
n_sequences, n_periods, n_treatments, n_subjects, sequences,
treatments, reference, replicate_reference, replicate_test,
reps_reference, reps_test, balanced, and feasible (a named logical
vector for abe, abel, rsabe, ntid, hvntid). reps_reference is
the median, over subjects, of the number of times a subject received the
reference. reps_test is the same median computed separately for each
test formulation; with several test formulations it is the smallest of
those medians, so replicate_test is TRUE only when every test
formulation is replicated.
Other Bioequivalence:
be_assess(),
be_compare(),
be_dataset(),
be_expand_limits(),
be_extract_param(),
be_fit_model_single(),
be_fit_models(),
be_regulator(),
be_table(),
be_within_var()
d <- data.frame( subject = rep(1:4, each = 4), period = rep(1:4, times = 4), sequence = rep(c("TRTR", "RTRT"), each = 8), treatment = c("T", "R", "T", "R", "R", "T", "R", "T", "T", "R", "T", "R", "R", "T", "R", "T") ) be_design(d, "subject", "sequence", "period", "treatment", reference_value = "R")d <- data.frame( subject = rep(1:4, each = 4), period = rep(1:4, times = 4), sequence = rep(c("TRTR", "RTRT"), each = 8), treatment = c("T", "R", "T", "R", "R", "T", "R", "T", "T", "R", "T", "R", "R", "T", "R", "T") ) be_design(d, "subject", "sequence", "period", "treatment", reference_value = "R")
be_expand_limits() computes the (possibly widened) bioequivalence
acceptance limits for a scaled-ABE framework given the within-reference
standard deviation. For EMA and Health Canada the limits widen
geometrically with swR and are capped; for the GCC they jump to a fixed
wider band; below the switching variability they remain the conventional
80.00-125.00%.
be_expand_limits(swR, regulator)be_expand_limits(swR, regulator)
swR |
The within-reference standard deviation of the log-transformed
endpoint (for example from |
regulator |
A regulator name (see |
A named numeric vector c(lower, upper) of acceptance limits as
percentages.
Other Bioequivalence:
be_assess(),
be_compare(),
be_dataset(),
be_design(),
be_extract_param(),
be_fit_model_single(),
be_fit_models(),
be_regulator(),
be_table(),
be_within_var()
be_expand_limits(0.485, "EMA") # capped expansion be_expand_limits(0.20, "EMA") # below the switch: 80-125% be_expand_limits(0.40, "GCC") # fixed GCC bandbe_expand_limits(0.485, "EMA") # capped expansion be_expand_limits(0.20, "EMA") # below the switch: 80-125% be_expand_limits(0.40, "GCC") # fixed GCC band
be_extract_param() turns a be_fit_model_single() fit into the parameters
the regulatory decision needs. It always computes the intra-subject-contrast
(ISC) point estimate, then dispatches on the model type to extract the
model-based geometric means, the geometric mean ratio and its confidence
interval, and the within-formulation standard deviations.
be_extract_param(fit, ds_ep, alpha = 0.1)be_extract_param(fit, ds_ep, alpha = 0.1)
fit |
A |
ds_ep |
The standardized single-endpoint data.frame from |
alpha |
The significance level; the confidence interval has level
|
A data.frame with one row per test formulation, carrying the model and ISC point estimates/intervals, geometric means, and within-formulation variances.
Other Bioequivalence:
be_assess(),
be_compare(),
be_dataset(),
be_design(),
be_expand_limits(),
be_fit_model_single(),
be_fit_models(),
be_regulator(),
be_table(),
be_within_var()
be_fit_model_single() fits the average-BE model for a single endpoint and
dispatches on model_type to be_fit_model_lmer(), be_fit_model_nlme(),
be_fit_model_gls(), or be_fit_model_anova(). This is the only place
model fitting happens. For the "lmer", "anova", and "isc" types the
within-formulation ANOVA variances are also fit here; for "nlme" they come
from the single mixed model. Covariate columns carried by be_dataset()
(.cov_<name>) enter every model as additive fixed effects.
be_fit_model_single( ds_ep, model_type = c("lmer", "nlme", "anova", "isc", "gls"), scaling = TRUE )be_fit_model_single( ds_ep, model_type = c("lmer", "nlme", "anova", "isc", "gls"), scaling = TRUE )
ds_ep |
The standardized single-endpoint data.frame from |
model_type |
One of |
scaling |
Logical; whether reference scaling is needed (controls whether the within-formulation variances are estimated). |
An object of class be_fit: a list with model_type, the fitted
model, and (for lmer/anova/isc) ref_var/test_var within-formulation
ANOVA variances. The endpoint's measurement units are attached as a units
attribute (NULL when not provided).
Other Bioequivalence:
be_assess(),
be_compare(),
be_dataset(),
be_design(),
be_expand_limits(),
be_extract_param(),
be_fit_models(),
be_regulator(),
be_table(),
be_within_var()
be_fit_models() runs the single bioequivalence calculation path and returns
the regulatory pass/fail table. It coordinates the stages in order:
be_dataset() to prepare the data, be_design() to classify the design and
choose the model, be_fit_model_single() to fit, be_extract_param() to
extract the parameters, and be_table() to apply the regulatory decision.
be_assess() and be_compare() are thin verbs over it.
be_fit_models( object, reference_col, reference_value, endpoints = c("cmax", "aucinf.obs", "aucinf.pred", "auclast"), regulator = "ABE", model_type = NULL, alpha = 0.1, subject = NULL, sequence = NULL, period = NULL, design = NULL, covariates = NULL, heteroscedastic = FALSE )be_fit_models( object, reference_col, reference_value, endpoints = c("cmax", "aucinf.obs", "aucinf.pred", "auclast"), regulator = "ABE", model_type = NULL, alpha = 0.1, subject = NULL, sequence = NULL, period = NULL, design = NULL, covariates = NULL, heteroscedastic = FALSE )
object |
A |
reference_col |
The column identifying the formulation/treatment. |
reference_value |
The value of |
endpoints |
Character vector of NCA parameters (matched against
|
regulator |
The regulatory framework (see |
model_type |
The model for the average-BE point estimate, one of
|
alpha |
The significance level; the confidence interval has level
|
subject, sequence, period
|
Column names for the subject, randomization
sequence, and period. When |
design |
An optional |
covariates |
An optional character vector of column names added to
every model as additive fixed effects (numeric columns as linear terms,
character or factor columns as factors). They must not be missing in any
analyzed row. For a |
heteroscedastic |
Logical. When |
A data.frame with one row per endpoint and test formulation (the
columns described in be_assess()).
Other Bioequivalence:
be_assess(),
be_compare(),
be_dataset(),
be_design(),
be_expand_limits(),
be_extract_param(),
be_fit_model_single(),
be_regulator(),
be_table(),
be_within_var()
be_regulator() returns the scaling type, switching and capping rules, and
regulatory constants that define a bioequivalence (BE) assessment framework.
It is the single source of truth for these values: be_assess() and the
internal decision functions pull every constant from here rather than
hard-coding it.
be_regulator( name = c("ABE", "EMA", "HC", "GCC", "FDA", "NTID", "HVNTID", "descriptive") )be_regulator( name = c("ABE", "EMA", "HC", "GCC", "FDA", "NTID", "HVNTID", "descriptive") )
name |
The regulatory framework, one of |
The supported frameworks and their constants are:
ABE – average bioequivalence; the universal unscaled criterion that the 90% confidence interval fall within 80.00-125.00%. No reference scaling.
EMA – average bioequivalence with expanding limits (ABEL). Scaling
begins when the within-reference coefficient of variation (CVwR) exceeds
30% (cvswitch = 0.30); the limits widen as exp(+/- k * swR) with the
regulatory constant k = 0.76 and the expansion is capped at CVwR = 50%
(limits 69.84-143.19%). The constant 0.76 is
log(1.25) / sqrt(log(1 + 0.30^2)) rounded to two decimals, as fixed by
the EMA bioequivalence guideline.
HC – Health Canada; ABEL with the same k = 0.76 but the expansion is
capped at CVwR = 57.382% (upper limit 150%).
GCC – Gulf Cooperation Council; fixed widened limits of
75.00-133.33% whenever CVwR > 30% (not CV-dependent).
FDA – reference-scaled average bioequivalence (RSABE). The linearized
(Howe/Hyslop) criterion uses r_const = log(1.25) / 0.25 = 0.8926
(theta = r_const^2) and switches from unscaled ABE when swR >= 0.294
(CVwR of about 30%).
NTID – FDA narrow therapeutic index drugs; uses
r_const = -log(0.9) / 0.1 = 1.0536 and always applies the scaled
criterion (a fully replicated design is required).
HVNTID – FDA highly variable narrow therapeutic index drugs; the RSABE-style scaled criterion with the NTID constant and the within-subject standard deviation ratio constraint.
descriptive – no regulatory decision. The geometric means, their ratio, and its confidence interval are estimated exactly as for ABE, but no acceptance limits are applied and no pass/fail is reported. Use it for comparisons that are estimated rather than judged, such as food effect and drug-drug interaction studies.
All decision frameworks additionally impose the point-estimate constraint that the geometric mean ratio fall within 80.00-125.00%.
An object of class be_regulator: a list with elements name,
scaling (one of "none", "abel", "rsabe", "ntid", "hvntid"),
cvswitch, r_const, cvcap, switch_swr, pe_constr, est_method
("anova" or "isc"), decision (FALSE only for "descriptive"), and
switch_basis.
be_expand_limits() for the ABEL acceptance limits and be_assess()
for the full assessment.
Other Bioequivalence:
be_assess(),
be_compare(),
be_dataset(),
be_design(),
be_expand_limits(),
be_extract_param(),
be_fit_model_single(),
be_fit_models(),
be_table(),
be_within_var()
be_regulator("EMA") be_regulator("FDA") be_regulator("descriptive")be_regulator("EMA") be_regulator("FDA") be_regulator("descriptive")
be_table() takes the parameters from be_extract_param() and a regulatory
framework and produces the final per-endpoint pass/fail table. It selects the
regulator-appropriate statistic (the model contrast for the expanding-limits
frameworks, intra-subject contrasts for the FDA family) and calls the
per-framework decision functions; it is the only place regulator decisions
are made.
be_table( params, regulator, alpha = 0.1, design = NA_character_, model_type = NA_character_ )be_table( params, regulator, alpha = 0.1, design = NA_character_, model_type = NA_character_ )
params |
A data.frame of parameters from |
regulator |
A regulator name or a |
alpha |
The significance level. |
design |
The design label (character) for the |
model_type |
The model type label for the |
A data.frame with one row per endpoint and test formulation and the
pass/fail decision columns. For the "descriptive" framework the decision
columns (limit_lower, limit_upper, criterion, and pass) are omitted.
Other Bioequivalence:
be_assess(),
be_compare(),
be_dataset(),
be_design(),
be_expand_limits(),
be_extract_param(),
be_fit_model_single(),
be_fit_models(),
be_regulator(),
be_within_var()
be_within_var() estimates the within-subject standard deviations of the
log-transformed endpoint separately for the reference (swR) and test
(swT) formulations, the quantities that reference-scaling frameworks need.
The default model_type = "anova" is an analysis of variance (ANOVA) of the
replicate observations within each formulation; this is the estimator used by
both Method A and Method B of the EMA replicateBE reference implementation
and by the FDA moment-based approach, and it works for full and partial
replicate designs. model_type = "nlme" instead fits a single mixed model
with treatment-specific residual variances and requires a fully replicated
design; it is provided as the alternative described in the FDA progesterone
guidance and can differ slightly from "anova".
be_within_var( data, value, subject, period, treatment, reference_value, model_type = c("anova", "nlme"), alpha = 0.1 )be_within_var( data, value, subject, period, treatment, reference_value, model_type = c("anova", "nlme"), alpha = 0.1 )
data |
A long data.frame with one row per observation for a single endpoint (subject, period, treatment, and the endpoint value). |
value |
The column name of the (untransformed) endpoint value; it is log-transformed internally. |
subject, period, treatment
|
Column names identifying the subject, period, and treatment. |
reference_value |
The value of |
model_type |
|
alpha |
The significance level for the |
An object of class be_within_var: a list with swR, swT,
s2wR, s2wT, cvwr_percent, cvwt_percent, df_wR, df_wT,
sw_ratio (= swT/swR), sw_ratio_ci_upper (the upper 1 - alpha
confidence bound of the ratio), model_type, and alpha. swT and the
ratio are NA when the test formulation is not replicated (for example a
partial replicate design).
Other Bioequivalence:
be_assess(),
be_compare(),
be_dataset(),
be_design(),
be_expand_limits(),
be_extract_param(),
be_fit_model_single(),
be_fit_models(),
be_regulator(),
be_table()
Generate functions to do the named function (e.g. mean) applying the business rules.
business.mean(x, ...) business.sd(x, ...) business.cv(x, ...) business.geomean(x, ...) business.geocv(x, ...) business.min(x, ...) business.max(x, ...) business.median(x, ...) business.range(x, ...)business.mean(x, ...) business.sd(x, ...) business.cv(x, ...) business.geomean(x, ...) business.geocv(x, ...) business.min(x, ...) business.max(x, ...) business.median(x, ...) business.range(x, ...)
x |
vector to be passed to the various functions |
... |
Additional arguments to be passed to the underlying function. |
The value of the various functions or NA if too many values are missing
business.sd(): Compute the standard deviation with business rules.
business.cv(): Compute the coefficient of variation with business rules.
business.geomean(): Compute the geometric mean with business rules.
business.geocv(): Compute the geometric coefficient of variation with business rules.
business.min(): Compute the minimum with business rules.
business.max(): Compute the maximum with business rules.
business.median(): Compute the median with business rules.
business.range(): Compute the range with business rules.
Check that the conversion to a data type does not change the number of NA values
check.conversion(x, FUN, ...)check.conversion(x, FUN, ...)
x |
the value to convert |
FUN |
the function to use for conversion |
... |
arguments passed to |
FUN(x, ...) or an error if the set of NAs change.
Calculation interval specifications are data frames defining what calculations will be required and summarized from all time intervals. Note: parameters which are not requested may be calculated if it is required for (or computed at the same time as) a requested parameter.
check.interval.specification(x, impute = NA_character_)check.interval.specification(x, impute = NA_character_)
x |
The data frame specifying what to calculate during each time interval |
impute |
The |
start and end time must always be given as columns, and the start must
be before the end. Other columns define the parameters to be calculated
and the groupings to apply the intervals to.
Data are selected for calculation within an interval by the time of the
measurement or dose: a row is included when its time is at or after start
and at or before end (a dose exactly at end is not included in the
interval). For duration data (for example, urine collections or intravenous
infusions), the time is the start of the collection or administration, and
the duration is not considered during selection: a collection that starts
within the interval and ends after end is included and contributes its
full amount to the interval. For the simplest interpretation of results,
align collection start and end times with interval boundaries.
x The potentially updated data frame with the interval calculation specification.
The vignette "Selection of Calculation Intervals"
Other Interval specifications:
add.interval.col(),
choose.auc.intervals(),
get.interval.cols(),
get.parameter.deps(),
interval_add_impute(),
interval_add_param(),
interval_add_secondary(),
pknca_cdisc_codes(),
pknca_check_parameter_classification(),
pknca_concepts(),
pknca_interval_table(),
pknca_match_route(),
pknca_parameter_table(),
pknca_presets(),
pknca_ref()
Check the hash of an object to confirm its provenance.
checkProvenance(object)checkProvenance(object)
object |
The object to check provenance for |
TRUE if the provenance is confirmed to be consistent, FALSE if
the provenance is not consistent, or NA if provenance is not present.
An object that was modified after it was created by a PKNCA function that
marks provenance (for example dplyr::filter(), dplyr::mutate(),
exclude(), or normalize() on a PKNCAresults object) has a hash such
as "filtered from <hash>" instead of the original hash and always gives
FALSE.
Choose how to interpolate, extrapolate, or integrate data in each concentration interval
choose_interval_method(conc, time, tlast, method, auc.type, options)choose_interval_method(conc, time, tlast, method, auc.type, options)
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
tlast |
Time of last concentration above the limit of quantification (will be calculated, if not provided) |
method |
The method for integration (one of 'lin up/log down', 'lin-log', or 'linear') |
auc.type |
The type of AUC to compute. Choices are 'AUCinf', 'AUClast', and 'AUCall'. |
options |
List of changes to the default PKNCA options (see
|
A character vector of methods for interpolation/extrapolation
methods that is the same length as conc which indicates how to
interpolate/integrate between each of the concentrations (all but the last
value in the vector) and how to extrapolate after tlast (the last item in
the vector). Possible values in the vector are: 'zero', 'linear', 'log',
and 'extrap_log'
Intervals are selected by the following metrics:
If there are no dose times, no intervals are generated and a
"pknca_warning_no_dose_times_for_group" warning is given.
If only one dose is administered and any sample follows it, the
interval runs from the dose to infinity with the parameters
pknca_interval_table() gives for a single dose.
If more than one dose is administered, an interval is generated between any two consecutive doses that have samples at both dose times and at least one sample between them. It is a dosing interval when the samples run up to the next dose, and a single-dose profile bounded by the next dose when they stop partway and leave a washout.
For the final dose, the dosing interval () is found with
find.tau(). An interval one long is generated when a
sample was taken at its end, with the parameters for a dose at steady
state. It starts at the first dose of the last complete cycle, which
is the last dose itself unless the regimen gives more than one dose
per , so that the interval never contains a dose that was
not recorded.
If samples continue beyond after the last dose, the
half-life is calculated from the last dose onward. If the last dose
has samples after it but gets neither of these, its profile is
calculated to infinity as a single dose.
choose.auc.intervals( time.conc, time.dosing, options = list(), single.dose.aucs = NULL, route = "extravascular", sparse = FALSE, timeu = NULL, time.conc.nominal = NULL, time.dosing.nominal = NULL, dense.samples = 3, conc = NULL )choose.auc.intervals( time.conc, time.dosing, options = list(), single.dose.aucs = NULL, route = "extravascular", sparse = FALSE, timeu = NULL, time.conc.nominal = NULL, time.dosing.nominal = NULL, dense.samples = 3, conc = NULL )
time.conc |
Time of concentration measurement |
time.dosing |
Time of dosing |
options |
List of changes to the default PKNCA options (see
|
single.dose.aucs |
The AUC specification for single dosing. |
route |
How the drug was given, as one of |
sparse |
Is this a sparse sampling design? A sparse design imputes
nothing; see |
timeu |
The time unit of |
time.conc.nominal, time.dosing.nominal
|
Nominal times of the samples
and of the doses, on the same scale as |
dense.samples |
The fewest samples within one dosing period after a dose that make it sampled densely, which gives it an interval after a change of regimen |
conc |
The concentrations at |
When find.dose.regimen() finds a change of regimen in the dose times (more
than one segment) and the design is not sparse, the intervals follow the
segments instead:
One steady-state interval for each segment, when a sample ends it. An earlier segment's interval is its last complete cycle, from the cycle's first dose to the recorded dose one period later (the dose that starts the next segment, unless a dose was missed before it), so it never contains a later dose. The last segment's interval is its last cycle, one period at the segment's own period. Like the interval after the last dose, a steady-state interval needs only a sample at its end, so it may have as few as two samples.
The interval after the first dose, as above.
The interval after any other dose only when the dose is sampled
densely: at least dense.samples samples (3 by default) strictly
within one period of its segment after the dose. A sample counts by
its nominal time when it has one (time.conc.nominal), from the
dose's nominal time when that is given (time.dosing.nominal), so
that a sample drawn a little late counts where it was scheduled; a
sample without a nominal time counts by its actual time. Samples at
the same time count once, and samples without a concentration
(conc is NA) do not count; samples below the limit of
quantification do. Nominal times must share the actual times'
origin (time since the first dose, for example). When they restart
instead, as times since the latest dose do, the actual times are
used with a "pknca_warning_intervals_nominal_restart" warning.
The last dose gets the intervals above at the period of the last segment, even when an earlier segment has more doses.
A "pknca_warning_intervals_by_segment" warning names the segments and the
intervals chosen. It is also a "pknca_warning_tau_regimen_change" warning,
which it replaces.
is matched to the nominal dosing intervals of
find.dose.regimen() in the time unit timeu, taken to be hours when it is
not given: dose times recorded a little early or late give the nominal
interval, and an interval that matches none of them, such as dosing every
hour, gives a "pknca_warning_tau_not_nominal" warning. With timeu = NA
(a unit PKNCA cannot use), is found from the dose times alone.
Times are matched within a tolerance rather than exactly, so a sample drawn a
little before its nominal time still bounds the interval it belongs to. The
window is the auto.interval.tolerance option as a fraction of the
interval's length, and it only reaches backward: a sample drawn after a
boundary belongs to what follows that boundary, so a concentration drawn
after a dose cannot stand in for the predose sample.
Setting the auto.interval.method option to "legacy" calculates the
parameter lists PKNCA used before pknca_interval_table() was available:
the single.dose.aucs option for single-dose data, and AUClast, Cmax, and
Tmax for each interval of multiple-dose data. The intervals themselves are
found the same way either way.
A data frame with columns for start, end, and the parameters to
calculate. See check.interval.specification() for column definitions.
The data frame may have zero rows if no intervals could be found.
pknca_interval_table(), pk.calc.auc(), pk.calc.half.life(),
PKNCA.options()
Other Interval specifications:
add.interval.col(),
check.interval.specification(),
get.interval.cols(),
get.parameter.deps(),
interval_add_impute(),
interval_add_param(),
interval_add_secondary(),
pknca_cdisc_codes(),
pknca_check_parameter_classification(),
pknca_concepts(),
pknca_interval_table(),
pknca_match_route(),
pknca_parameter_table(),
pknca_presets(),
pknca_ref()
Other Interval determination:
find.dose.regimen(),
find.tau(),
resolve_dose_tau()
# A single dose gives one profile to infinity choose.auc.intervals(c(0, 1, 2, 4, 8, 24), 0)[, c("start", "end")] # Daily dosing with a dense profile on the first and last day choose.auc.intervals( c(0, 1, 2, 4, 8, 12, 24, 48, 72, 96, 120, 144, 145, 146, 148, 152, 156, 168, 192), seq(0, 144, by = 24) )[, c("start", "end")]# A single dose gives one profile to infinity choose.auc.intervals(c(0, 1, 2, 4, 8, 24), 0)[, c("start", "end")] # Daily dosing with a dense profile on the first and last day choose.auc.intervals( c(0, 1, 2, 4, 8, 12, 24, 48, 72, 96, 120, 144, 145, 146, 148, 152, 156, 168, 192), seq(0, 144, by = 24) )[, c("start", "end")]
Handle BLQ values in the concentration measurements as requested by the user.
clean.conc.blq( conc, time, ..., options = list(), conc.blq = NULL, conc.na = NULL, check = TRUE )clean.conc.blq( conc, time, ..., options = list(), conc.blq = NULL, conc.na = NULL, check = TRUE )
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
... |
Additional arguments passed to clean.conc.na |
options |
List of changes to the default PKNCA options (see
|
conc.blq |
How to handle a BLQ value that is between above LOQ values? See details for description. |
conc.na |
How to handle NA concentrations. (See |
check |
Run |
NA concentrations (and their associated times) will be handled as
described in clean.conc.na() before working with the BLQ values. The
method for handling NA concentrations can affect the output of which points
are considered BLQ and which are considered "middle". Values are
considered BLQ if they are 0.
conc.blq can be set either a scalar indicating what should be done for
all BLQ values or a list with elements either named "first", "middle" and "last" or "before.tmax" and "after.tmax"
each set to a scalar.
The meaning of each of the list elements is:
Values up to the first non-BLQ value. Note that if all values are BLQ, this includes all values.
Values that are BLQ between the first and last non-BLQ values.
Values that are BLQ after the last non-BLQ value
Values that are BLQ before the time at first maximum concentration
Values that are BLQ after the time at first maximum concentration
The valid settings for each are:
Drop the BLQ values
Keep the BLQ values
Set the BLQ values to that number
The concentration and time measurements (data frame) filtered and cleaned as requested relative to BLQ in the middle.
Other Data cleaners:
clean.conc.na()
NA concentrations (and their associated times) will be removed then the BLQ values in the middle
clean.conc.na(conc, time, ..., options = list(), conc.na = NULL, check = TRUE)clean.conc.na(conc, time, ..., options = list(), conc.na = NULL, check = TRUE)
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
... |
Additional items to add to the data frame |
options |
List of changes to the default PKNCA options (see
|
conc.na |
How to handle NA concentrations? Either 'drop' or a number to impute. |
check |
Run |
The concentration and time measurements (data frame) filtered and cleaned as requested relative to NA in the concentration.
Other Data cleaners:
clean.conc.blq()
The calculation follows equation A3 in Holder 2001 (see references below):
cov_holder(sparse_pk)cov_holder(sparse_pk)
sparse_pk |
A sparse_pk object from |
If , then is
defined as zero (rather than dividing by zero).
Where:
The covariance of times i and j
and
The number of subjects (usually animals) at times i and j, respectively
The number of subjects (usually animals) at both times i and j
and
The concentration measured for animal k at times i and j, respectively
and
The mean of the concentrations at times i and j, respectively
The Cauchy-Schwartz inequality is enforced for covariances to keep correlation coefficients between -1 and 1, inclusive, as described in equations 8 and 9 of Nedelman and Jia 1998.
A matrix with one row and one column for each element of
sparse_pk_attribute. The covariances are on the off diagonals, and for
simplicity of use, it also calculates the variance on the diagonal
elements.
Holder DJ. Comments on Nedelman and Jia’s Extension of Satterthwaite’s Approximation Applied to Pharmacokinetics. Journal of Biopharmaceutical Statistics. 2001;11(1-2):75-79. doi:10.1081/BIP-100104199
Nedelman JR, Jia X. An extension of Satterthwaite’s approximation applied to pharmacokinetics. Journal of Biopharmaceutical Statistics. 1998;8(2):317-328. doi:10.1080/10543409808835241
The following functions are defunct
check.conc.time(...)check.conc.time(...)
... |
Ignored |
check.conc.time(): Defunct as of version 0.11
Checks if specified unit columns exist in a PKNCA object (either PKNCAconc or PKNCAdose). If the columns do not exist, it creates them and assigns default values (NA or existing units).
ensure_column_unit_exists(pknca_obj, unit_name)ensure_column_unit_exists(pknca_obj, unit_name)
pknca_obj |
A PKNCA object (either PKNCAconc or PKNCAdose). |
unit_name |
A character vector of unit column names to ensure (concu, amountu, timeu...). |
The function performs the following steps:
Checks if the specified unit columns exist in the PKNCA object.
If a column does not exist, it creates the column and assigns default values.
If not default values are provided, it assigns NA to the new column.
The updated PKNCA object with ensured unit columns.
Exclude data points or results from calculations or summarization.
exclude(object, reason, mask, FUN) ## Default S3 method: exclude(object, reason, mask, FUN)exclude(object, reason, mask, FUN) ## Default S3 method: exclude(object, reason, mask, FUN)
object |
The object to exclude data from. |
reason |
The reason to add as a reason for exclusion. |
mask |
A logical vector or numeric index of values to exclude (see details). |
FUN |
A function to operate on the data (one group at a time) to select reasons for exclusions (see details). |
Only one of mask or FUN may be given. If FUN is given, it
will be called with two arguments: a data.frame (or similar object) that
consists of a single group of the data and the full object (e.g. the
PKNCAconc object), FUN(current_group, object), and it must return a
logical vector equivalent to mask or a character vector with the reason
text given when data should be excluded or NA_character_ when the data
should be included (for the current exclusion test).
The object with updated information in the exclude column. The
exclude column will contain the reason if mask or FUN indicate. If a
previous reason for exclusion was given, then subsequent reasons for
exclusion will be added to the first with a semicolon space ("; ")
separator.
exclude(default): The general case for data exclusion
Other Result exclusions:
exclude_nca,
pknca_exclude_rules(),
pknca_missing_samples()
myconc <- PKNCAconc(data.frame(subject=1, time=0:6, conc=c(1, 2, 3, 2, 1, 0.5, 0.25)), conc~time|subject) exclude(myconc, reason="Carryover", mask=c(TRUE, rep(FALSE, 6)))myconc <- PKNCAconc(data.frame(subject=1, time=0:6, conc=c(1, 2, 3, 2, 1, 0.5, 0.25)), conc~time|subject) exclude(myconc, reason="Carryover", mask=c(TRUE, rep(FALSE, 6)))
Exclude NCA parameters based on examining the parameter set.
exclude_nca_span.ratio(min.span.ratio) exclude_nca_max.aucinf.pext(max.aucinf.pext) exclude_nca_count_conc_measured( min_count, exclude_param_pattern = c("^aucall", "^aucinf", "^aucint", "^auciv", "^auclast", "^aumc", "^sparse_auc") ) exclude_nca_min.hl.r.squared(min.hl.r.squared) exclude_nca_min.hl.adj.r.squared(min.hl.adj.r.squared = 0.9) exclude_nca_tmax_early(tmax_early = 0) exclude_nca_tmax_0() exclude_nca_tmax_coverage(min_subjects = 4, k_warn = 1.5, k_exclude = 3)exclude_nca_span.ratio(min.span.ratio) exclude_nca_max.aucinf.pext(max.aucinf.pext) exclude_nca_count_conc_measured( min_count, exclude_param_pattern = c("^aucall", "^aucinf", "^aucint", "^auciv", "^auclast", "^aumc", "^sparse_auc") ) exclude_nca_min.hl.r.squared(min.hl.r.squared) exclude_nca_min.hl.adj.r.squared(min.hl.adj.r.squared = 0.9) exclude_nca_tmax_early(tmax_early = 0) exclude_nca_tmax_0() exclude_nca_tmax_coverage(min_subjects = 4, k_warn = 1.5, k_exclude = 3)
min.span.ratio |
The minimum acceptable span ratio (uses PKNCA.options("min.span.ratio") if not provided). |
max.aucinf.pext |
The maximum acceptable percent AUC extrapolation (uses PKNCA.options("max.aucinf.pext") if not provided). |
min_count |
Minimum number of measured concentrations |
exclude_param_pattern |
Character vector of regular expression patterns to exclude |
min.hl.r.squared |
The minimum acceptable r-squared value for half-life (uses PKNCA.options("min.hl.r.squared") if not provided). |
min.hl.adj.r.squared |
The minimum acceptable adjusted r-squared for half-life (uses 0.9 if not provided). |
tmax_early |
The time for Tmax which is considered too early to be a valid NCA result |
min_subjects |
The fewest subjects with a Tmax in a group for the group to be checked (smaller groups are not checked, with a message) |
k_warn |
The multiple of the interquartile range that sets the inner fences; a subject with no sample within them gets a warning |
k_exclude |
The multiple of the interquartile range that sets the outer fences (at least k_warn); a subject with no sample within them is excluded |
A function to give to exclude() as FUN. Its
pknca_affected_parameters attribute lists the parameters it can exclude,
and its pknca_options attribute lists the PKNCA.options() entries its
thresholds came from (see pknca_exclude_rules()).
exclude_nca_span.ratio(): Exclude based on the half-life span ratio
exclude_nca_max.aucinf.pext(): Exclude based on the percent of AUC extrapolated to infinity (both observed and predicted)
exclude_nca_count_conc_measured(): Exclude based on the count of concentrations measured and not below the lower limit of quantification (affects AUC and AUMC parameters)
exclude_nca_min.hl.r.squared(): Exclude based on half-life r-squared
exclude_nca_min.hl.adj.r.squared(): Exclude based on half-life adjusted r-squared
exclude_nca_tmax_early(): Exclude based on implausibly early Tmax (often used for extravascular dosing with a Tmax value of 0)
exclude_nca_tmax_0(): Exclude based on implausibly early Tmax (special case for tmax_early = 0)
exclude_nca_tmax_coverage(): Exclude based on whether a subject has a sample within Tukey's fences around the Tmax values of its group; the rule flags a subject with no sample within the inner fences, and excludes only a subject with no sample within the outer fences
exclude_nca_tmax_coverage() compares each subject's samples with the
Tmax values of its group; it flags a subject whose samples miss the usual
Tmax times, and excludes only beyond the outer fences. The group is the
summary group of summary.PKNCAresults(): every grouping column except
the subject, with the interval start and end (so each part, treatment,
analyte, and interval is its own group). From the first and third
quartiles of the Tmax values of every subject in the group (the subject
being judged included), Tukey's inner fences are the quartiles extended
by k_warn times the interquartile range, and the outer fences by
k_exclude times it. The quartiles are those of
stats::quantile(type = 7), the default type; with few subjects, the
types differ (Tmax values of 1, 1, 2, 2, 1, and 8 give a third quartile
of 2 with type 7, 3.5 with type 6, and 2.5 with type 8). Tmax values
that are missing or already excluded are not used. The ranges never
start before the interval start, where a reported range starts when its
lower fence is below it. A sample at the interval start counts only when
the subject's dose at or before the interval start is an intravascular
bolus (route intravascular and no duration or a duration of zero in
PKNCAdose()), so a predose sample does not count after an extravascular
dose or when the results have no dose data.
The samples are the concentration rows with an actual time within the
interval (the rows that pk.nca() used) that have a concentration and
are not excluded. When the concentration data have a nominal time
(time.nominal in PKNCAconc()), the samples are placed by their
nominal time minus the interval start, so the nominal times must share
the origin of the interval times (for example, the nominal time since the
first dose); otherwise, they are placed by their actual time. The
Tmax values are placed the same way: with nominal times, a subject's
Tmax is the nominal time of the sample it was found at, so an offset
between the actual and nominal times moves the fences and the samples
together. A subject whose Tmax sample has no nominal time does not enter
the fences, and a subject whose samples in the interval have no nominal
time at all is not judged, with a
pknca_message_tmax_coverage_no_nominal_subject message. Times are
never converted between units, and the time unit is only used in the
text.
A subject with no sample within the outer fences is excluded: every parameter of that interval is excluded with a reason that gives the outer range and the subject's sample nearest to it.
A subject with a sample within the outer fences but none within the
inner fences is flagged as a possible data issue and not excluded: a
pknca_warning_tmax_coverage_outlier warning has the fields group (a
one-row data.frame with the group and subject), tmax_range (the inner
range, relative to the interval start), and nearest_sample (the
subject's sample nearest to it, relative to the interval start).
With nominal times, a subject with a sample within the inner fences
that is missing some of the group's nominal times within them (see
pknca_missing_samples()) gets a pknca_message_tmax_coverage_partial
message that Cmax and Tmax may be unreliable. Its fields are group,
tmax_range, time_nominal_missing, and reason (as in
pknca_missing_samples()). Without nominal times, there is no
schedule to compare with, and no message is given.
The warnings and messages can be caught with withCallingHandlers().
A group with fewer than min_subjects subjects with a Tmax on the
basis of the fences (one subject, for example) is not checked, and a
pknca_message_tmax_coverage_few_subjects message says so once per
group. Quartiles of fewer than four values describe the spread of the
group poorly.
When the nominal times disagree with the interval, the group is not
checked, and a pknca_warning_tmax_coverage_no_nominal warning says so
once per group. They disagree when no nominal time of the group is
after the interval start, when most samples of the group with an
actual time in the interval have a nominal time outside it, or when a
subject's nominal times go back to the start of its schedule while its
actual times increase within the interval, as when the nominal times
restart at each dose.
Sparse data have one Tmax per group, from the mean profile, so they are
not checked, and a pknca_message_tmax_coverage_sparse message says so
once per call to exclude().
Other Result exclusions:
exclude(),
pknca_exclude_rules(),
pknca_missing_samples()
my_conc <- PKNCAconc(data.frame(conc=1.1^(3:0), time=0:3, subject=1), conc~time|subject) my_data <- PKNCAdata(my_conc, intervals=data.frame(start=0, end=Inf, aucinf.obs=TRUE, aucpext.obs=TRUE)) my_result <- pk.nca(my_data) my_result_excluded <- exclude(my_result, FUN=exclude_nca_max.aucinf.pext()) as.data.frame(my_result_excluded)my_conc <- PKNCAconc(data.frame(conc=1.1^(3:0), time=0:3, subject=1), conc~time|subject) my_data <- PKNCAdata(my_conc, intervals=data.frame(start=0, end=Inf, aucinf.obs=TRUE, aucpext.obs=TRUE)) my_result <- pk.nca(my_data) my_result_excluded <- exclude(my_result, FUN=exclude_nca_max.aucinf.pext()) as.data.frame(my_result_excluded)
Exclude rows from NCA results based on specified thresholds for a given parameter. This function allows users to define minimum and/or maximum acceptable values for a parameter and excludes rows that fall outside these thresholds.
exclude_nca_by_param( parameter, min_thr = NULL, max_thr = NULL, affected_parameters = parameter )exclude_nca_by_param( parameter, min_thr = NULL, max_thr = NULL, affected_parameters = parameter )
parameter |
The name of the PKNCA parameter to evaluate (e.g., "span.ratio"). |
min_thr |
The minimum acceptable value for the parameter. If not provided, is not applied. |
max_thr |
The maximum acceptable value for the parameter. If not provided, is not applied. |
affected_parameters |
Character vector of PKNCA parameters that will be marked as excluded. By default is the defined parameter. |
A function that can be used with PKNCA::exclude to mark through the 'exclude' column
the rows in the PKNCA results based on the specified thresholds for a parameter.
Its pknca_affected_parameters attribute lists the parameters it can mark
(see pknca_exclude_rules()).
# Example dataset my_data <- PKNCA::PKNCAdata( PKNCA::PKNCAconc(data.frame(conc = 5:1, time = 0:4, subject = 1), conc ~ time | subject), PKNCA::PKNCAdose(data.frame(subject = 1, dose = 100, time = 0), dose ~ time | subject) ) my_result <- PKNCA::pk.nca(my_data) # Exclude rows where span.ratio is less than 2 excluded_result <- PKNCA::exclude( my_result, FUN = exclude_nca_by_param("span.ratio", min_thr = 2) ) as.data.frame(excluded_result)# Example dataset my_data <- PKNCA::PKNCAdata( PKNCA::PKNCAconc(data.frame(conc = 5:1, time = 0:4, subject = 1), conc ~ time | subject), PKNCA::PKNCAdose(data.frame(subject = 1, dose = 100, time = 0), dose ~ time | subject) ) my_result <- PKNCA::pk.nca(my_data) # Exclude rows where span.ratio is less than 2 excluded_result <- PKNCA::exclude( my_result, FUN = exclude_nca_by_param("span.ratio", min_thr = 2) ) as.data.frame(excluded_result)
Rows are selected by their time falling within the interval: start <= time and time <= end (or time < end when include_end=FALSE). For
duration data (for example, urine collections or intravenous infusions),
time is the start of the collection or administration, and the duration
column is not consulted during selection: a record whose duration starts
within the interval and ends after the interval end is selected and
contributes its full amount to calculations within the interval. For the
simplest interpretation of results, align collection start and end times
with interval boundaries.
filter_interval(data, start, end, include_na = FALSE, include_end = TRUE)filter_interval(data, start, end, include_na = FALSE, include_end = TRUE)
data |
A data.frame with a column named |
start, end
|
The beginning and end times of the interval |
include_na |
Should rows with an |
include_end |
Should a row with |
The rows of data selected for the interval
Filtering a PKNCAconc or PKNCAdose object filters its data. Filtering a
PKNCAresults object filters the result table and, when the filter only
uses group columns (the columns after the | in the PKNCAconc formula), the
concentration data, the dose data, and the intervals of x$data as well, so
that the filtered results are consistent with their data. Only those three
are filtered; group_ref and units of the PKNCAdata are not.
## S3 method for class 'PKNCAresults' filter(.data, ..., .by = NULL, .preserve = FALSE) ## S3 method for class 'PKNCAconc' filter(.data, ..., .by = NULL, .preserve = FALSE) ## S3 method for class 'PKNCAdose' filter(.data, ..., .by = NULL, .preserve = FALSE)## S3 method for class 'PKNCAresults' filter(.data, ..., .by = NULL, .preserve = FALSE) ## S3 method for class 'PKNCAconc' filter(.data, ..., .by = NULL, .preserve = FALSE) ## S3 method for class 'PKNCAdose' filter(.data, ..., .by = NULL, .preserve = FALSE)
.data |
A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details. |
... |
< |
.by |
< |
.preserve |
Relevant when the |
The filter is evaluated once, on the result table. The groups that remain
there are the groups kept: the rows of the concentration data, dose data, and
intervals are kept when their values in the group columns that they share
with the result table match a remaining group. A table that has none of
those group columns (for example, intervals with no group columns) is left
whole, and groups that have no rows in the result table are dropped from the
data. Because the filter is evaluated only on the results, any filter that
aggregates over rows (such as ID == max(ID)) keeps the same groups in every
table.
A filter that uses any other column of the result table (such as PPTESTCD,
PPORRES, or exclude), or that uses no column of the result table, filters
the result table only. Columns are recognized when the expressions name them
(part == "SAD", .data$part == "SAD", and the columns of .by).
Variables of the calling environment are not treated as columns. Filters
that choose columns without naming them (.data[[var]], across(),
if_any(), if_all(), pick(), and tidyselect helpers such as all_of()
or starts_with()) filter the result table only, with a message that the
data were not filtered. The columns start and end belong to the result
table, so a filter on them leaves the data unchanged.
mutate() and the joins change only the result table; assigning into the
object directly is the caller's responsibility and is not tracked.
A PKNCAresults object that a PKNCA dplyr verb changes (filter(),
mutate(), group_by(), ungroup(), and the joins) no longer matches the
hash that checkProvenance() verifies: the hash is replaced by a marker such
as "filtered from <hash>" and checkProvenance() returns FALSE. A call
that leaves the object identical keeps its provenance.
Other dplyr verbs:
group_by.PKNCAresults(),
inner_join.PKNCAresults(),
mutate.PKNCAresults()
The dose times are sorted and times that repeat are dropped. The regimen is then described as one or more segments, each a stretch of dosing that repeats over a period, found in this order:
Equally spaced doses repeat over their spacing.
A cycle of 2 to 4 doses per period that every dose follows is looked
for next. The period is the median span of that many spacings,
refined by least squares, and each dose's time within the period
falls into one of the positions of the cycle. The spacings between
the positions must differ from one another by more than tol, every
dose must be within snap.tol of the period of its position, and
every position must hold at least two doses (two complete periods).
The positions must also explain the scatter of the doses: the doses
sit at most half as far from their positions as the spacings sit
from their median, and the positions fit the doses better than
evenly spaced positions by more than chance (an F test at the 0.999
level). Daily doses recorded a few hours early or late are therefore
daily dosing, not a cycle. Twice-daily doses at 08:00 and 16:00 repeat
every 24 hours with offsets 0 and 8. When the period is not one of
the given tau.choices and a whole number of periods is, that
multiple is used if the doses hold two complete repeats of it (so a
48 hour choice selects two days of twice-daily dosing only when there
are at least nine doses); the built-in nominal set never selects a
longer period.
Doses whose spacings are all within tol of their median are evenly
spaced with scatter, and repeat over the median spacing.
Otherwise, each spacing is labeled with the candidate it is within
tol of (on the log scale), and the rest are clustered on the log
scale. Doses squeezed into one interval between two runs of the
regimen are set aside as extra doses. Runs of at least min.run
spacings with one label anchor segments, and the runs must hold most
of the spacings. A spacing outside the runs is a missed dose when it
is a whole number (up to max.missed) of the segment's interval and
is irregular when it is not; a dose given early or late is the dose
between two irregular spacings. Neighboring anchors with the same
label are one segment, so a change of regimen gives several segments.
When that reading has missed or irregular doses or more than one segment, a cycle of 2 to 4 doses that at least 70% of the doses follow is used instead if it explains more spacings, or as many with no more missed, off-schedule, or extra doses and changes of regimen. This keeps three-times-daily dosing with a dose not given as three times daily, and daily dosing after twice-daily dosing as a change of regimen.
If none of that fits, there is no repeating interval.
find.dose.regimen( x, tau.choices = NULL, timeu = NULL, options = list(), tol = 0.2, snap.tol = 0.1, min.run = 2, max.missed = 4 )find.dose.regimen( x, tau.choices = NULL, timeu = NULL, options = list(), tol = 0.2, snap.tol = 0.1, min.run = 2, max.missed = 4 )
x |
Dose times for one subject, as numbers |
tau.choices |
The nominal intervals to match, in the unit of |
timeu |
The time unit of |
options |
List of changes to the default PKNCA options (see
|
tol |
Relative tolerance for grouping spacings with one another and with a candidate |
snap.tol |
Relative tolerance for reporting an interval as a candidate and for a dose to be on a cycle's pattern |
min.run |
The fewest consecutive spacings with one label that form a segment |
max.missed |
The largest multiple of the interval that is read as missed doses |
The interval of a segment is snapped to the nearest candidate within
snap.tol (source "nominal"), and is otherwise the value found in the data
(source "auto"). The value found in the data is the median of the
spacings (or spans) that set it, so scatter in the recorded times does not
move it. The candidates are tau.choices when it is given. Otherwise they
are the built-in nominal intervals, converted from hours to timeu: Q4H (4
hours), QID (6), TID (8), BID (12), QD (24), QOD (48), Q72H (72), QW (168),
Q2W (336), Q3W (504), Q4W (672), Q6W (1008), Q8W (1344), and Q12W (2016).
Without a time unit, the times are taken to be hours, as PKNCA takes
date-times to be, so dose times 24 and 26 hours apart are once-daily dosing.
Times recorded in another unit without saying so are then compared with
intervals in hours, and an interval that matches none of them gives a
"pknca_warning_tau_not_nominal" warning; give timeu to avoid that.
timeu = NA says that the unit is not one PKNCA can use, and the intervals
then come from the data alone (every source is "auto"). Converting a unit
other than "hr" needs the units package; without it, such a unit gives a
"pknca_message_tau_units_fallback" message and the intervals come from the
data alone, so results for data in other units can differ between
installations with and without that package.
A data frame with one row per segment and the columns:
segmentThe segment number
start, end
The first and last dose time of the segment; a dose where the regimen changes ends one segment and starts the next
n_dosesThe number of doses in the segment
intervalThe period that the dose pattern repeats over, NA for a
single dose or when nothing repeats
labelThe name of the candidate for an evenly spaced regimen with
the segment's number of doses per period (twice-daily doses at 0 and 10
hours are "BID"), or NA
source"nominal" when interval is a candidate and "auto" when
it was found in the data
n_intervals_usedThe spacings that set the interval
n_missedDoses read as missed
n_irregularDoses off schedule or extra
noteA description of anything unusual
offsetsA list column of the dose times within one period, relative to the first dose of the period
With no dose times, the data frame has no rows.
pknca_warning_tau_irregular_dosingA segment has missed doses (the message names the dose times before them) or doses off schedule (the message names those doses).
pknca_warning_tau_not_nominalThere were candidates to match (any
timeu other than NA) and a segment matched none of them. The message
includes the regimen table.
pknca_warning_tau_regimen_changeMore than one segment was found. The message includes the regimen table.
pknca_warning_dose_regimenThe parent class of the three warnings above, to handle them together.
pknca_message_tau_units_fallbacktimeu is not "hr" and the
units package is not installed to convert it, so the intervals come from
the data alone.
pknca_error_regimen_time_unittimeu cannot be converted to
hours.
pknca_error_regimen_time_classx is a date-time or difftime
rather than a number.
find.tau(), which gives the interval of the segment with the most
doses
Other Interval determination:
choose.auc.intervals(),
find.tau(),
resolve_dose_tau()
# Daily dosing with the times as recorded find.dose.regimen(c(0, 23.6, 48, 72.4, 96), timeu = "hr") # Twice daily at breakfast and dinner repeats daily find.dose.regimen(c(0, 10, 24, 34, 48, 58), timeu = "hr") # Daily, then twice daily suppressWarnings( find.dose.regimen(c(0, 24, 48, 72, 84, 96, 108, 120), timeu = "hr") )# Daily dosing with the times as recorded find.dose.regimen(c(0, 23.6, 48, 72.4, 96), timeu = "hr") # Twice daily at breakfast and dinner repeats daily find.dose.regimen(c(0, 10, 24, 34, 48, 58), timeu = "hr") # Daily, then twice daily suppressWarnings( find.dose.regimen(c(0, 24, 48, 72, 84, 96, 108, 120), timeu = "hr") )
The regimen is found with find.dose.regimen(), and the interval is the
period of its segment with the most doses (the latest of those when segments
tie). In brief, the dose times are sorted and times that repeat are dropped;
equally spaced doses give their spacing; a pattern of more than one dose per
interval that repeats over at least two complete intervals gives the interval
it repeats over; doses scattered within a tolerance of one spacing give their
median spacing; and otherwise runs of the same spacing form the regimen, with
the gaps between them read as missed doses (a whole number of intervals) or
doses off schedule. Times are compared on the log scale within tol and
snap.tol of find.dose.regimen(), so a dose recorded at 23.6 hours is a
daily dose.
find.tau( x, na.action = stats::na.omit, options = list(), tau.choices = NULL, timeu = NULL )find.tau( x, na.action = stats::na.omit, options = list(), tau.choices = NULL, timeu = NULL )
x |
the vector to find the interval within |
na.action |
What to do with NAs in |
options |
List of changes to the default PKNCA options (see
|
tau.choices |
The nominal intervals to match, in the unit of |
timeu |
The time unit of |
Looking for a repeating pattern before reading anything as a missed dose is what keeps a regimen with a regular gap in it, such as dosing three times a day at 0, 6, and 12 hours, from being reported as a 6 hour interval with a dose missing overnight.
The intervals are matched to tau.choices when it is given. When it is NA
(the default), they are matched to the built-in nominal intervals listed in
find.dose.regimen(), in the unit timeu. Without a time unit, the times
are taken to be hours, so find.tau(c(0, 24, 50)) is 24 (once daily)
rather than the median spacing of 25; times in another unit should give
timeu, or they are compared with intervals in hours and an interval that
matches none of them gives a "pknca_warning_tau_not_nominal" warning.
The warnings of find.dose.regimen() are given here as well, notably
"pknca_warning_tau_irregular_dosing" for missed doses or doses off schedule.
NA when there are no dose times or no interval repeats, 0 for a
single dose time, and otherwise the repeating interval.
Other Interval determination:
choose.auc.intervals(),
find.dose.regimen(),
resolve_dose_tau()
# Equally spaced doses give their spacing find.tau(c(0, 24, 48, 72)) # Twice-daily dosing repeats daily although no two doses are a day apart find.tau(c(0, 10, 24, 34, 48, 58), tau.choices = c(12, 24)) # Dose times as recorded, with the unit known find.tau(c(0, 23.6, 48, 72.4, 96), timeu = "hr")# Equally spaced doses give their spacing find.tau(c(0, 24, 48, 72)) # Twice-daily dosing repeats daily although no two doses are a day apart find.tau(c(0, 10, 24, 34, 48, 58), tau.choices = c(12, 24)) # Dose times as recorded, with the unit known find.tau(c(0, 23.6, 48, 72.4, 96), timeu = "hr")
Find the first occurrence of an operator in a formula and return the left, right, or both sides of the operator.
findOperator(x, op, side)findOperator(x, op, side)
x |
The formula to parse |
op |
The operator to search for (e.g. |
side |
Which side of the operator would you like to see: 'left', 'right', or 'both'. |
The side of the operator requested, NA if requesting the left side of a unary operator, and NULL if the operator is not found.
Other Formula parsing:
parse_formula_to_cols()
Perform the half-life fit given the data. The function simply fits the data without any validation. No selection of points or any other components are done.
fit_half_life(data, tlast)fit_half_life(data, tlast)
data |
The data to fit. Must have two columns named "log_conc" and "time" |
tlast |
The time of last observed concentration above the limit of quantification. |
A named list with one value each for "r.squared", "adj.r.squared",
"lambda.z.corrxy", "lambda.z", "clast.pred", "lambda.z.time.first",
"lambda.z.time.last", "lambda.z.n.points", "half.life", and "span.ratio".
pk.calc.half.life() fits one candidate per span of terminal points and
builds a data.frame from the candidate it selects.
Perform a Tobit half-life fit given the data. The function fits the data using maximum likelihood without any point selection or validation.
fit_half_life_tobit(data, tlast, optim_control = list())fit_half_life_tobit(data, tlast, optim_control = list())
data |
The data to fit. Must have columns named |
tlast |
The time of last observed concentration above the lower limit of quantification. |
optim_control |
A list of control parameters passed to |
A data.frame with one row and columns named "lambda.z",
"clast.pred", "lambda.z.time.first", "lambda.z.time.last",
"lambda.z.n.points", "lambda.z.n.points_blq", "half.life",
"span.ratio", "tobit_residual", and "adj_tobit_residual".
Returns NA for all columns if stats::optim() does not converge,
and emits a warning.
pk.calc.half.life(), fit_half_life_tobit_LL()
Helper function used by fit_half_life_tobit() via stats::optim().
For observations above the LLOQ, the normal density contributes to the
likelihood. For censored (BLQ) observations, the normal CDF up to the
LLOQ contributes.
fit_half_life_tobit_LL(par, log_conc, time, mask_blq, log_lloq)fit_half_life_tobit_LL(par, log_conc, time, mask_blq, log_lloq)
par |
A 3-element numeric vector: |
log_conc |
Natural log of observed concentration (may be |
time |
Numeric time vector |
mask_blq |
Logical vector; |
log_lloq |
Natural log of the lower limit of quantification |
The negative sum of the log-likelihood (a scalar)
fit_half_life_tobit()
Extract the formula from a PKNCAconc object.
## S3 method for class 'PKNCAconc' formula(x, ...) ## S3 method for class 'PKNCAdose' formula(x, ...)## S3 method for class 'PKNCAconc' formula(x, ...) ## S3 method for class 'PKNCAdose' formula(x, ...)
x |
The object to extract the formula from. |
... |
Unused |
A formula object
Compute the geometric mean, sd, and CV
geomean(x, na.rm = FALSE) geosd(x, na.rm = FALSE) geocv(x, na.rm = FALSE)geomean(x, na.rm = FALSE) geosd(x, na.rm = FALSE) geocv(x, na.rm = FALSE)
x |
A vector to compute the geometric mean of |
na.rm |
Should missing values be removed? |
The scalar value of the geometric mean, geometric standard deviation, or geometric coefficient of variation.
geosd(): Compute the geometric standard deviation, exp(sd(log(x))).
geocv(): Compute the geometric coefficient of variation,
sqrt(exp(sd(log(x))^2)-1)*100.
Kirkwood T. B.L. Geometric means and measures of dispersion. Biometrics 1979; 35: 908-909
geomean(1:3) geosd(1:3) geocv(1:3)geomean(1:3) geosd(1:3) geocv(1:3)
Concentrations are given as concentrations, not log-concentrations. Take the
natural log of conc if the log-concentration is wanted.
get_halflife_curve( object, tout = NULL, n = 50, extrapolate_earlier = FALSE, extrapolate_later = TRUE )get_halflife_curve( object, tout = NULL, n = 50, extrapolate_earlier = FALSE, extrapolate_later = TRUE )
object |
A PKNCAresults or PKNCAdata object |
tout |
Times for output. The same times are used for every group and
interval. If |
n |
The number of equally-spaced times to generate when |
extrapolate_earlier, extrapolate_later
|
Should concentrations be
extrapolated before the first ( |
Like stats::approx(), give either tout for specific times or n for
equally-spaced times. With n, the times span the concentrations used for
the fit (time_first to time_last from get_halflife_fit()), so tout is
required to extrapolate.
A data.frame with the grouping columns, the interval start and
end times, and the columns:
time: the time of the concentration, on the same scale as the times in
the concentration data
conc: the concentration on the half-life fit at that time
conc is NA where the half-life could not be calculated or was excluded,
and where extrapolation was requested but not allowed. Groups without a
fit give a single row with an NA time when tout is NULL, since no
times can be generated for them.
get_halflife_fit() for the slope and intercept of the fit, and
get_halflife_points() for the concentrations used for it
o_conc <- PKNCAconc(Theoph, conc~Time|Subject) o_data <- PKNCAdata(o_conc, intervals = data.frame(start = 0, end = Inf, half.life = TRUE)) o_nca <- pk.nca(o_data) # Equally-spaced times across the fit head(get_halflife_curve(o_nca)) # Specific times, extrapolating past the last concentration used get_halflife_curve(o_nca, tout = c(12, 24, 36))o_conc <- PKNCAconc(Theoph, conc~Time|Subject) o_data <- PKNCAdata(o_conc, intervals = data.frame(start = 0, end = Inf, half.life = TRUE)) o_nca <- pk.nca(o_data) # Equally-spaced times across the fit head(get_halflife_curve(o_nca)) # Specific times, extrapolating past the last concentration used get_halflife_curve(o_nca, tout = c(12, 24, 36))
The half-life fit is the log-linear regression of concentration on time,
log(conc) = intercept + slope*time. Concentrations along the line are
exp(intercept + slope*time).
get_halflife_fit(object)get_halflife_fit(object)
object |
A PKNCAresults or PKNCAdata object |
Times in a PKNCAresults object are relative to the start of the interval,
but time_first, time_last, and the time scale of intercept are on the
same scale as the times in the concentration data so that the line can be
drawn with the observed concentrations.
A data.frame with one row for each group and interval where
half-life was calculated. Along with the grouping columns and the interval
start and end times, it has the columns:
intercept: the natural log of the concentration where the line crosses
time 0
slope: the slope of the line, -lambda.z
time_first, time_last: the first and last times of the concentrations
used for the fit
intercept and slope are NA when the half-life could not be
calculated or was excluded.
get_halflife_points() to see which concentrations were used for
the fit
o_conc <- PKNCAconc(Theoph, conc~Time|Subject) o_data <- PKNCAdata(o_conc, intervals = data.frame(start = 0, end = Inf, half.life = TRUE)) o_nca <- pk.nca(o_data) get_halflife_fit(o_nca)o_conc <- PKNCAconc(Theoph, conc~Time|Subject) o_data <- PKNCAdata(o_conc, intervals = data.frame(start = 0, end = Inf, half.life = TRUE)) o_nca <- pk.nca(o_data) get_halflife_fit(o_nca)
Determine which concentrations were used for half-life calculation
get_halflife_points(object)get_halflife_points(object)
object |
A PKNCAresults or PKNCAdata object |
A logical vector with TRUE if the point was used for half-life
(including concentrations below the limit of quantification within the
range of times for calculation), FALSE if it was not used for half-life
but the half-life was calculated for the interval, and NA if half-life
was not calculated for the interval. If a row is excluded from all
calculations, it is set to NA as well.
o_conc <- PKNCAconc(Theoph, conc~Time|Subject) o_data <- PKNCAdata(o_conc, intervals = data.frame(start = 0, end = Inf, half.life = TRUE)) o_nca <- pk.nca(o_data) get_halflife_points(o_nca)o_conc <- PKNCAconc(Theoph, conc~Time|Subject) o_data <- PKNCAdata(o_conc, intervals = data.frame(start = 0, end = Inf, half.life = TRUE)) o_nca <- pk.nca(o_data) get_halflife_points(o_nca)
get_impute_column() applies the first two of the three readings of
impute described in get_impute_method() and says which column
get_impute_method() reads the methods from. It does not read the column,
so it does not check that the column is character.
get_impute_column(intervals, impute)get_impute_column(intervals, impute)
intervals |
the data.frame of intervals |
impute |
the imputation definition – either the name of a column in
|
The name of the column of intervals that the methods come from
(character scalar): impute when it names a column of intervals, or
"impute" when impute is NA and intervals has a column named
"impute". NULL when impute is itself the method string, or is NA
and there is no "impute" column, so there is no column.
Other Imputation:
PKNCA_impute_fun_list(),
PKNCA_impute_method,
assert_impute_method(),
get_impute_method(),
pknca_impute_methods()
intervals <- data.frame(start = 0, end = 24, impute = "start_conc0", my_impute = "start_cmin") get_impute_column(intervals, impute = "my_impute") get_impute_column(intervals, impute = NA) # A method string is not a column get_impute_column(intervals, impute = "start_predose") # NA without an "impute" column is not a column either get_impute_column(intervals[, c("start", "end")], impute = NA)intervals <- data.frame(start = 0, end = 24, impute = "start_conc0", my_impute = "start_cmin") get_impute_column(intervals, impute = "my_impute") get_impute_column(intervals, impute = NA) # A method string is not a column get_impute_column(intervals, impute = "start_predose") # NA without an "impute" column is not a column either get_impute_column(intervals[, c("start", "end")], impute = NA)
get_impute_method() is the rule pk.nca() uses to find the imputation
methods for each interval, from the impute argument of PKNCAdata() and
the intervals. It reads impute one of three ways, in this order:
get_impute_method(intervals, impute)get_impute_method(intervals, impute)
intervals |
the data.frame of intervals |
impute |
the imputation definition – either the name of a column in
|
If impute is the name of a column in intervals, the methods are that
column's values, one per interval. The name may be any column name, not
only "impute".
Otherwise, if impute is NA and intervals has a column named
"impute", the methods are that column's values, one per interval.
Otherwise impute is itself the method (or comma- or space-separated
methods) for every interval, and the result is impute as a single
value. An NA that finds no "impute" column therefore gives a single
NA_character_, meaning no imputation.
get_impute_method() only reads the specification. It does not check that
the methods exist; assert_impute_method() does. get_impute_column()
gives the name of the column the methods are read from, which tells a column
from a method string even for an intervals table with one row.
A character vector of imputation specifications: one per row of
intervals when read from a column, and of length one otherwise (the
method string, or NA_character_ for no imputation). A column that is
not character is an error, except that a column of only NA (which is
logical when made with NA) is read as no imputation.
Other Imputation:
PKNCA_impute_fun_list(),
PKNCA_impute_method,
assert_impute_method(),
get_impute_column(),
pknca_impute_methods()
intervals <- data.frame(start = 0, end = 24, impute = "start_conc0") # The column named by `impute` get_impute_method(intervals, impute = "impute") # NA finds the column named "impute" get_impute_method(intervals, impute = NA) # NA without an "impute" column means no imputation get_impute_method(intervals[, c("start", "end")], impute = NA) # Anything else is the method for every interval get_impute_method(intervals, impute = "start_predose")intervals <- data.frame(start = 0, end = 24, impute = "start_conc0") # The column named by `impute` get_impute_method(intervals, impute = "impute") # NA finds the column named "impute" get_impute_method(intervals, impute = NA) # NA without an "impute" column means no imputation get_impute_method(intervals[, c("start", "end")], impute = NA) # Anything else is the method for every interval get_impute_method(intervals, impute = "start_predose")
Extract the best model from a list of models using the AIC.
get.best.model(object, ...)get.best.model(object, ...)
object |
the list of models |
... |
Passed to |
The model which is assessed as best. If more than one are equal, the first is chosen.
Get the columns that can be used in an interval specification
get.interval.cols()get.interval.cols()
A list with named elements for each parameter. Each list element contains the parameter definition.
check.interval.specification() and the vignette "Selection of
Calculation Intervals"
Other Interval specifications:
add.interval.col(),
check.interval.specification(),
choose.auc.intervals(),
get.parameter.deps(),
interval_add_impute(),
interval_add_param(),
interval_add_secondary(),
pknca_cdisc_codes(),
pknca_check_parameter_classification(),
pknca_concepts(),
pknca_interval_table(),
pknca_match_route(),
pknca_parameter_table(),
pknca_presets(),
pknca_ref()
get.interval.cols()get.interval.cols()
Get all columns that depend on a parameter
get.parameter.deps(x, recursive = FALSE)get.parameter.deps(x, recursive = FALSE)
x |
The parameter name (as a character string) |
recursive |
Search backward to the inputs |
The two directions answer different questions. The default
answers "what becomes invalid if x changes?". recursive = TRUE
answers "what does x need?", and its result mixes parameter names
with the raw inputs the calculation ends at, such as "conc",
"time", "dose", and "time.dose".
With recursive = FALSE (default), a character vector of
parameter names that depend on the parameter x; empty if none do.
With recursive = TRUE, the unique set of everything x is calculated
from, following each dependency to the end.
Other Interval specifications:
add.interval.col(),
check.interval.specification(),
choose.auc.intervals(),
get.interval.cols(),
interval_add_impute(),
interval_add_param(),
interval_add_secondary(),
pknca_cdisc_codes(),
pknca_check_parameter_classification(),
pknca_concepts(),
pknca_interval_table(),
pknca_match_route(),
pknca_parameter_table(),
pknca_presets(),
pknca_ref()
Retrieve the value of an attribute column.
getAttributeColumn(object, attr_name, warn_missing = c("attr", "column"))getAttributeColumn(object, attr_name, warn_missing = c("attr", "column"))
object |
The object to extract the attribute value from. |
attr_name |
The name of the attribute to extract |
warn_missing |
Give a warning if the "attr"ibute or "column" is missing. Character vector with zero, one, or both of "attr" and "column". |
The value of the attribute (or NULL if the attribute is not set or
the column does not exist)
Get the value from a column in a data frame if the value is a column there, otherwise, the value should be a scalar or the length of the data.
getColumnValueOrNot(data, value, prefix = "X")getColumnValueOrNot(data, value, prefix = "X")
data |
A data.frame or similar object |
value |
A character string giving the name of a column in the |
prefix |
The prefix to use if a column must be added (it will be used as the full column name if it is not already in the dataset or it will be prepended to the maximum column name if not.) |
A list with elements named "data", "name" giving the data with a
column named "name" with the value in that column.
Get the name of the element containing the data for the current object.
## S3 method for class 'PKNCAconc' getDataName(object) ## S3 method for class 'PKNCAdose' getDataName(object) ## S3 method for class 'PKNCAresults' getDataName(object) getDataName(object) ## Default S3 method: getDataName(object)## S3 method for class 'PKNCAconc' getDataName(object) ## S3 method for class 'PKNCAdose' getDataName(object) ## S3 method for class 'PKNCAresults' getDataName(object) getDataName(object) ## Default S3 method: getDataName(object)
object |
The object to get the data name from. |
A character scalar with the name of the data object (or NULL if the
method does not apply).
getDataName(default): If no data name exists, returns NULL.
Other PKNCA object extractors:
getDepVar(),
getIndepVar()
Get the dependent variable (left hand side of the formula) from a PKNCA object.
getDepVar(x, ...)getDepVar(x, ...)
x |
The object to extract the formula from |
... |
Unused |
The vector of the dependent variable from the object.
Other PKNCA object extractors:
getDataName.PKNCAconc(),
getIndepVar()
| from a PKNCA
object).Get the groups (right hand side after the | from a PKNCA
object).
Get the groups (right hand side after the | from a PKNCA
object).
## S3 method for class 'PKNCAconc' getGroups( object, form = stats::formula(object), level, data = as.data.frame(object), sep ) ## S3 method for class 'PKNCAdata' getGroups(object, ...) ## S3 method for class 'PKNCAdose' getGroups(...) ## S3 method for class 'PKNCAresults' getGroups( object, form = formula(as_PKNCAconc(object)), level, data = as.data.frame(object), sep )## S3 method for class 'PKNCAconc' getGroups( object, form = stats::formula(object), level, data = as.data.frame(object), sep ) ## S3 method for class 'PKNCAdata' getGroups(object, ...) ## S3 method for class 'PKNCAdose' getGroups(...) ## S3 method for class 'PKNCAresults' getGroups( object, form = formula(as_PKNCAconc(object)), level, data = as.data.frame(object), sep )
object |
The object to extract the data from |
form |
The formula to extract the data from (defaults to the formula
from |
level |
optional. If included, this specifies the level(s) of the
groups to include. If a numeric scalar, include the first |
data |
The data to extract the groups from (defaults to the data from
|
sep |
Unused (kept for compatibility with the nlme package) |
... |
Arguments passed to other getGroups functions |
A data frame with the (selected) group columns.
A data frame with the (selected) group columns.
Get the independent variable (right hand side of the formula) from a PKNCA object.
getIndepVar(x, ...)getIndepVar(x, ...)
x |
The object to extract the formula from |
... |
Unused |
The vector of the independent variable from the object.
Other PKNCA object extractors:
getDataName.PKNCAconc(),
getDepVar()
dplyr grouping for PKNCA
## S3 method for class 'PKNCAresults' group_by(.data, ..., .add = FALSE, .drop = dplyr::group_by_drop_default(.data)) ## S3 method for class 'PKNCAconc' group_by(.data, ..., .add = FALSE, .drop = dplyr::group_by_drop_default(.data)) ## S3 method for class 'PKNCAdose' group_by(.data, ..., .add = FALSE, .drop = dplyr::group_by_drop_default(.data)) ## S3 method for class 'PKNCAresults' ungroup(x, ...) ## S3 method for class 'PKNCAconc' ungroup(x, ...) ## S3 method for class 'PKNCAdose' ungroup(x, ...)## S3 method for class 'PKNCAresults' group_by(.data, ..., .add = FALSE, .drop = dplyr::group_by_drop_default(.data)) ## S3 method for class 'PKNCAconc' group_by(.data, ..., .add = FALSE, .drop = dplyr::group_by_drop_default(.data)) ## S3 method for class 'PKNCAdose' group_by(.data, ..., .add = FALSE, .drop = dplyr::group_by_drop_default(.data)) ## S3 method for class 'PKNCAresults' ungroup(x, ...) ## S3 method for class 'PKNCAconc' ungroup(x, ...) ## S3 method for class 'PKNCAdose' ungroup(x, ...)
.data |
A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details. |
... |
< |
.add |
When |
.drop |
Drop groups formed by factor levels that don't appear in the
data? The default is |
x |
A |
Other dplyr verbs:
filter.PKNCAresults(),
inner_join.PKNCAresults(),
mutate.PKNCAresults()
Get grouping variables for a PKNCA object
## S3 method for class 'PKNCAconc' group_vars(x) ## S3 method for class 'PKNCAdata' group_vars(x) ## S3 method for class 'PKNCAdose' group_vars(x) ## S3 method for class 'PKNCAresults' group_vars(x)## S3 method for class 'PKNCAconc' group_vars(x) ## S3 method for class 'PKNCAdata' group_vars(x) ## S3 method for class 'PKNCAdose' group_vars(x) ## S3 method for class 'PKNCAresults' group_vars(x)
x |
The PKNCA object |
A character vector (possibly empty) of the grouping variables
group_vars(PKNCAdata): Get group_vars for a PKNCAdata object
from the PKNCAconc object within
group_vars(PKNCAdose): Get group_vars for a PKNCAdose object
group_vars(PKNCAresults): Get group_vars for a PKNCAresults object
from the PKNCAconc object within
dplyr joins for PKNCA
## S3 method for class 'PKNCAresults' inner_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAresults' left_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAresults' right_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAresults' full_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAconc' inner_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAconc' left_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAconc' right_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAconc' full_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAdose' inner_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAdose' left_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAdose' right_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAdose' full_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE )## S3 method for class 'PKNCAresults' inner_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAresults' left_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAresults' right_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAresults' full_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAconc' inner_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAconc' left_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAconc' right_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAconc' full_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAdose' inner_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAdose' left_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAdose' right_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE ) ## S3 method for class 'PKNCAdose' full_join( x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE )
x, y
|
A pair of data frames, data frame extensions (e.g. a tibble), or lazy data frames (e.g. from dbplyr or dtplyr). See Methods, below, for more details. |
by |
A join specification created with If To join on different variables between To join by multiple variables, use a
For simple equality joins, you can alternatively specify a character vector
of variable names to join by. For example, To perform a cross-join, generating all combinations of |
copy |
If |
suffix |
If there are non-joined duplicate variables in |
... |
Other parameters passed onto methods. |
keep |
Should the join keys from both
|
Other dplyr verbs:
filter.PKNCAresults(),
group_by.PKNCAresults(),
mutate.PKNCAresults()
Interpolate or extrapolate concentrations using the provided method
interpolate_conc_linear(conc_1, conc_2, time_1, time_2, time_out) interpolate_conc_log(conc_1, conc_2, time_1, time_2, time_out) extrapolate_conc_lambdaz(clast, lambda.z, tlast, time_out)interpolate_conc_linear(conc_1, conc_2, time_1, time_2, time_out) interpolate_conc_log(conc_1, conc_2, time_1, time_2, time_out) extrapolate_conc_lambdaz(clast, lambda.z, tlast, time_out)
conc_1, conc_2
|
The concentration at time1 and time2 |
time_1, time_2
|
The time value associated with conc1 and conc2 |
time_out |
Time when interpolation is requested |
clast |
The concentration at the last time above the lower LOQ |
lambda.z |
The elimination rate (in units of inverse time) for extrapolation |
tlast |
The time of the last concentration above the lower limit of quantification (LOQ) |
The interpolated or extrapolated value using the correct method
interpolate.conc() and extrapolate.conc() returns an interpolated (or
extrapolated) concentration. interp.extrap.conc() will choose whether
interpolation or extrapolation is required and will also operate on many
concentrations. These will typically be used to estimate the concentration
between two measured concentrations or after the last measured concentration.
Of note, these functions will not extrapolate prior to the first point.
interp.extrap.conc( conc, time, time.out, lambda.z = NA, clast = pk.calc.clast.obs(conc, time), options = list(), method = NULL, auc.type = "AUCinf", interp.method, extrap.method, ..., conc.blq = NULL, conc.na = NULL, check = TRUE ) interpolate.conc( conc, time, time.out, options = list(), method = NULL, interp.method, conc.blq = NULL, conc.na = NULL, conc.origin = 0, ..., check = TRUE ) extrapolate.conc( conc, time, time.out, lambda.z = NA, clast = pk.calc.clast.obs(conc, time), auc.type = "AUCinf", extrap.method, options = list(), conc.na = NULL, conc.blq = NULL, ..., check = TRUE ) interp.extrap.conc.dose( conc, time, time.dose, route.dose = "extravascular", duration.dose = NA, time.out, out.after = FALSE, options = list(), conc.blq = NULL, conc.na = NULL, ..., check = TRUE )interp.extrap.conc( conc, time, time.out, lambda.z = NA, clast = pk.calc.clast.obs(conc, time), options = list(), method = NULL, auc.type = "AUCinf", interp.method, extrap.method, ..., conc.blq = NULL, conc.na = NULL, check = TRUE ) interpolate.conc( conc, time, time.out, options = list(), method = NULL, interp.method, conc.blq = NULL, conc.na = NULL, conc.origin = 0, ..., check = TRUE ) extrapolate.conc( conc, time, time.out, lambda.z = NA, clast = pk.calc.clast.obs(conc, time), auc.type = "AUCinf", extrap.method, options = list(), conc.na = NULL, conc.blq = NULL, ..., check = TRUE ) interp.extrap.conc.dose( conc, time, time.dose, route.dose = "extravascular", duration.dose = NA, time.out, out.after = FALSE, options = list(), conc.blq = NULL, conc.na = NULL, ..., check = TRUE )
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
time.out |
Time when interpolation is requested (vector for
|
lambda.z |
The elimination rate (in units of inverse time) for extrapolation |
clast |
The last observed concentration above the limit of
quantification. If not given, |
options |
List of changes to the default PKNCA options (see
|
method |
The method for integration (one of 'lin up/log down', 'lin-log', or 'linear') |
auc.type |
The type of AUC to compute. Choices are 'AUCinf', 'AUClast', and 'AUCall'. |
interp.method, extrap.method
|
deprecated in favor of method and auc.type |
... |
Additional arguments passed to |
conc.blq |
How to handle a BLQ value that is between above LOQ values? See details for description. |
conc.na |
How to handle NA concentrations. (See |
check |
Run |
conc.origin |
The concentration before the first measurement.
|
time.dose |
Time of the dose |
route.dose |
What is the route of administration ("intravascular" or "extravascular"). See the details for how this parameter is used. |
duration.dose |
What is the duration of administration? See the details for how this parameter is used. |
out.after |
Should interpolation occur from the data before ( |
An NA value for the lambda.z parameter will prevent extrapolation.
Use lambda.z to extrapolate beyond the last point with the half-life.
If the last point is above the limit of quantification or missing, this is identical to 'AUCinf'. If the last point is below the limit of quantification, then linear interpolation between the Clast and the next BLQ is used for that interval and all additional points are extrapolated as 0.
Extrapolates all points after the last above the limit of quantification as 0.
duration.dose and direction.out are ignored if route.dose == "extravascular". direction.out is ignored if duration.dose > 0.
route.dose and duration.dose affect how interpolation/extrapolation of
the concentration occurs at the time of dosing. If route.dose == "intravascular" and duration.dose == 0 then extrapolation occurs for an IV
bolus using pk.calc.c0() with the data after dosing. Otherwise (either
route.dose == "extravascular" or duration.dose > 0), extrapolation occurs
using the concentrations before dosing and estimating the half-life (or more
precisely, estimating lambda.z). Finally, direction.out can change the
direction of interpolation in cases with route.dose == "intravascular" and
duration.dose == 0. When direction.out == "before" interpolation occurs
only with data before the dose (as is the case for route.dose == "extravascular"), but if direction.out == "after" interpolation occurs
from the data after dosing.
The interpolated or extrapolated concentration value as a scalar
double (or vector for interp.extrap.conc()).
interpolate.conc(): Interpolate concentrations through Tlast (inclusive)
extrapolate.conc(): Extrapolate concentrations after Tlast
interp.extrap.conc.dose(): Interpolate and extrapolate concentrations
without interpolating or extrapolating beyond doses.
pk.calc.clast.obs(), pk.calc.half.life(), pk.calc.c0()
Add or remove an imputation method in the intervals of a PKNCAdata object
interval_add_impute( data, target_impute, after = Inf, target_params = NULL, target_groups = NULL, ... ) interval_remove_impute( data, target_impute, target_params = NULL, target_groups = NULL, ... )interval_add_impute( data, target_impute, after = Inf, target_params = NULL, target_groups = NULL, ... ) interval_remove_impute( data, target_impute, target_params = NULL, target_groups = NULL, ... )
data |
A |
target_impute |
The imputation method to add or remove, as a character string (see PKNCA_impute_method). |
after |
Where to insert the method within any imputation already
present, following |
target_params |
Restrict the change to these NCA parameters. |
target_groups |
A data.frame of group values restricting the change to
matching intervals. Every column must match (and) for at least one row of
|
... |
Ignored. |
The input with the imputation updated. An interval is split into more than one row when its parameters no longer share the same imputation, and rows that come to share every value are merged.
interval_add_param(), PKNCAdata(), and the vignette
"Data Imputation"
Other Interval specifications:
add.interval.col(),
check.interval.specification(),
choose.auc.intervals(),
get.interval.cols(),
get.parameter.deps(),
interval_add_param(),
interval_add_secondary(),
pknca_cdisc_codes(),
pknca_check_parameter_classification(),
pknca_concepts(),
pknca_interval_table(),
pknca_match_route(),
pknca_parameter_table(),
pknca_presets(),
pknca_ref()
intervals <- data.frame(start = 0, end = 24, cmax = TRUE, half.life = TRUE) # Impute a starting concentration for everything in the interval interval_add_impute(intervals, target_impute = "start_conc0") # ... but not for half-life, which splits the interval into two rows interval_add_impute(intervals, target_impute = "start_conc0", target_params = "cmax")intervals <- data.frame(start = 0, end = 24, cmax = TRUE, half.life = TRUE) # Impute a starting concentration for everything in the interval interval_add_impute(intervals, target_impute = "start_conc0") # ... but not for half-life, which splits the interval into two rows interval_add_impute(intervals, target_impute = "start_conc0", target_params = "cmax")
Add or remove parameters in the intervals of a PKNCAdata object
interval_add_param( data, param = NULL, param_pattern = NULL, target_groups = NULL, ... ) interval_remove_param( data, param = NULL, param_pattern = NULL, target_groups = NULL, ... )interval_add_param( data, param = NULL, param_pattern = NULL, target_groups = NULL, ... ) interval_remove_param( data, param = NULL, param_pattern = NULL, target_groups = NULL, ... )
data |
A |
param |
A character vector of NCA parameter names. |
param_pattern |
A character vector of regular expressions matching NCA
parameter names. One or both of |
target_groups |
A data.frame of group values restricting the change to
matching intervals. Every column must match (and) for at least one row of
|
... |
Ignored. |
The input with the parameters added or removed.
interval_add_impute(), get.interval.cols()
Other Interval specifications:
add.interval.col(),
check.interval.specification(),
choose.auc.intervals(),
get.interval.cols(),
get.parameter.deps(),
interval_add_impute(),
interval_add_secondary(),
pknca_cdisc_codes(),
pknca_check_parameter_classification(),
pknca_concepts(),
pknca_interval_table(),
pknca_match_route(),
pknca_parameter_table(),
pknca_presets(),
pknca_ref()
intervals <- data.frame(start = 0, end = 24, cmax = TRUE, tmax = TRUE) interval_add_param(intervals, param = c("auclast", "half.life")) # At least one parameter must remain, so removing every one is an error interval_remove_param(intervals, param_pattern = "^tmax$")intervals <- data.frame(start = 0, end = 24, cmax = TRUE, tmax = TRUE) interval_add_param(intervals, param = c("auclast", "half.life")) # At least one parameter must remain, so removing every one is an error interval_remove_param(intervals, param_pattern = "^tmax$")
A secondary parameter needs a result from a second profile: renal clearance
divides an amount excreted in urine by a plasma AUC, an accumulation ratio
compares one dosing interval with another, and a metabolite ratio compares
two analytes. This adds the request and the linkage columns
(interval_id on the reference interval and <param>_ref on the intervals
calculating the parameter) that pk.nca() reads.
interval_add_secondary( data, param, reference = NULL, target_groups = NULL, ref_id = NULL, ... )interval_add_secondary( data, param, reference = NULL, target_groups = NULL, ref_id = NULL, ... )
data |
A |
param |
The name of one secondary NCA parameter (see
|
reference |
A data.frame describing the reference interval: its
columns are |
target_groups |
A data.frame of group values restricting the parameter
request to matching intervals, with the same matching rules as |
ref_id |
The |
... |
Ignored. |
The reference interval gains whatever the linked calculation reads from it (the plasma AUC for a renal clearance, for example) without being announced, as calculating any dependency is.
An interval that already names a different reference for param is left
alone with a pknca_warning_secondary_ref_exists warning, so that the
helper never silently re-points an analysis.
With reference = NULL the reference is derived from the data, which needs
a PKNCAdata object (a bare intervals data.frame carries no concentrations
to derive it from). The group_ref given to PKNCAdata() is used when it
is set. Otherwise the derivation applies where the parameter is measured on
an interval collection while everything it references is a spot sample
(renal clearance) and the concentration data declare a collection volume:
each interval takes the profile with no collection volume that differs from
its own in the fewest group columns. This is the same derivation
pk.nca() makes on its own, written out into the returned intervals
instead of being ephemeral. Anything the derivation cannot resolve is an
error here (pknca_error_secondary_needs_ref) rather than the NA result
the automatic path gives, so narrow the request with target_groups when
some intervals are not meant to calculate param.
When the parameter pairs an interval collection with spot-sample
references (renal clearance: an amount excreted against a plasma AUC)
and the reference interval is created by the PKNCAdata method, the
created interval spans the collections whole: a collection that begins
inside the interval contributes its full amount (see pk.nca()), so a
collection running past the interval's end extends the created
reference's end to time + duration of the latest collection. An
explicit end in reference overrides the extension, and the data.frame
method (which has no concentration data) copies the test interval's times
unchanged.
The input with the parameter requested and the linkage columns set,
after check.interval.specification().
interval_add_param(), pknca_ref(), pk.nca()
Other Interval specifications:
add.interval.col(),
check.interval.specification(),
choose.auc.intervals(),
get.interval.cols(),
get.parameter.deps(),
interval_add_impute(),
interval_add_param(),
pknca_cdisc_codes(),
pknca_check_parameter_classification(),
pknca_concepts(),
pknca_interval_table(),
pknca_match_route(),
pknca_parameter_table(),
pknca_presets(),
pknca_ref()
intervals <- data.frame( PCSPEC = c("plasma", "urine"), start = 0, end = 24, auclast = c(TRUE, FALSE), ae = c(FALSE, TRUE) ) interval_add_secondary( intervals, param = "clr.last", reference = data.frame(PCSPEC = "plasma") )intervals <- data.frame( PCSPEC = c("plasma", "urine"), start = 0, end = 24, auclast = c(TRUE, FALSE), ae = c(FALSE, TRUE) ) interval_add_secondary( intervals, param = "clr.last", reference = data.frame(PCSPEC = "plasma") )
Is a PKNCA object used for sparse PK?
## S3 method for class 'PKNCAconc' is_sparse_pk(object) ## S3 method for class 'PKNCAdata' is_sparse_pk(object) ## S3 method for class 'PKNCAresults' is_sparse_pk(object) is_sparse_pk(object)## S3 method for class 'PKNCAconc' is_sparse_pk(object) ## S3 method for class 'PKNCAdata' is_sparse_pk(object) ## S3 method for class 'PKNCAresults' is_sparse_pk(object) is_sparse_pk(object)
object |
The object to see if it includes sparse PK |
TRUE if sparse and FALSE if dense (not sparse)
Extract the columns used in the formula (in order) from a PKNCAconc or PKNCAdose object.
## S3 method for class 'PKNCAconc' model.frame(formula, ...) ## S3 method for class 'PKNCAdose' model.frame(formula, ...)## S3 method for class 'PKNCAconc' model.frame(formula, ...) ## S3 method for class 'PKNCAdose' model.frame(formula, ...)
formula |
The object to use (parameter name is |
... |
Unused |
A data frame with the columns from the object in formula order.
dplyr mutate-based modification for PKNCA
## S3 method for class 'PKNCAresults' mutate(.data, ...) ## S3 method for class 'PKNCAconc' mutate(.data, ...) ## S3 method for class 'PKNCAdose' mutate(.data, ...)## S3 method for class 'PKNCAresults' mutate(.data, ...) ## S3 method for class 'PKNCAconc' mutate(.data, ...) ## S3 method for class 'PKNCAdose' mutate(.data, ...)
.data |
A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details. |
... |
< The value can be:
|
Other dplyr verbs:
filter.PKNCAresults(),
group_by.PKNCAresults(),
inner_join.PKNCAresults()
Normalize parameters in a PKNCAresults object or data.frame
normalize(object, norm_table, parameters, suffix)normalize(object, norm_table, parameters, suffix)
object |
A PKNCAresults object or result data.frame |
norm_table |
data.frame with group columns, normalization values ( |
parameters |
character vector of parameter names to normalize |
suffix |
character value to add for the normalized parameter names |
A data.frame with normalized parameters
Normalize PKNCA results by a column of the concentration data
normalize_by_col(object, col, unit, parameters, suffix)normalize_by_col(object, col, unit, parameters, suffix)
object |
A PKNCAresults object |
col |
The column name from PKNCAconc to use for the normalization groups |
unit |
The unit of the previous column for normalization. Can be a column name in PKNCAconc or a single value. |
parameters |
Character vector of parameter names to normalize |
suffix |
Suffix to add to the normalized parameter code names |
A data.frame with normalized parameters
Normalize the exclude column by setting blanks to NA
normalize_exclude(object)normalize_exclude(object)
object |
The object to extract the exclude column from |
The exclude vector where NA indicates not to exclude and anything
else indicates to exclude.
Convert a formula representation to the columns for input data
parse_formula_to_cols(form)parse_formula_to_cols(form)
form |
the formula (or something coercible into a formula) to extract into its parts |
A list of column names for various formula parts
Other Formula parsing:
findOperator()
Convert the grouping info and list of results for each group into a results data.frame
pk_nca_result_to_df(group_info, result)pk_nca_result_to_df(group_info, result)
group_info |
A data.frame of grouping columns |
result |
A list of data.frames with the results from NCA parameter calculations |
A data.frame with group_info and result combined, warnings filtered out, and results unnested.
PKNCA.options("max.missing").Note that all missing values are removed prior to calling the function.
pk.business(FUN, zero.missing = FALSE, max.missing)pk.business(FUN, zero.missing = FALSE, max.missing)
FUN |
function to run. The function is called as |
zero.missing |
Are zeros counted as missing? If |
max.missing |
The maximum fraction of the data allowed to be missing (a number between 0 and 1, inclusive). |
A version of FUN that can be called with parameters that are checked
for missingness (and zeros) with missing (and zeros) removed before the
call. If max.missing is exceeded, then NA is returned.
my_mean <- pk.business(FUN=mean) mean(c(1:3, NA)) # Less than half missing results in the summary statistic of the available # values. my_mean(c(1:3, NA)) # More than half missing results in a missing value my_mean(c(1:3, rep(NA, 4)))my_mean <- pk.business(FUN=mean) mean(c(1:3, NA)) # Less than half missing results in the summary statistic of the available # values. my_mean(c(1:3, NA)) # More than half missing results in a missing value my_mean(c(1:3, rep(NA, 4)))
Calculate amount excreted (typically in urine or feces)
pk.calc.ae(conc, volume, check = TRUE)pk.calc.ae(conc, volume, check = TRUE)
conc |
Measured concentrations |
volume |
The volume (or mass) of the sample |
check |
Should the concentration and volume data be checked? |
ae is sum(conc*volume).
The units for the concentration and volume should match such that
sum(conc*volume) has units of mass or moles.
The amount excreted during the interval
Other Urine/Excretion parameters:
pk.calc.clr(),
pk.calc.erint(),
pk.calc.erlst(),
pk.calc.ermax(),
pk.calc.ertlst(),
pk.calc.ertmax(),
pk.calc.fe(),
pk.calc.volpk()
Concentrations below the given concentration (conc_above) will be set
to zero.
pk.calc.aucabove(conc, time, conc_above = NA_real_, ..., options = list())pk.calc.aucabove(conc, time, conc_above = NA_real_, ..., options = list())
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
conc_above |
The concentration threshold to calculate AUC above.
Must be finite ( |
... |
Extra arguments. Currently, the only extra argument that is used
is |
options |
List of changes to the default PKNCA options (see
|
The AUC of the concentration above the limit
These are the FUN_sparse of aucinf.obs and aumcinf.obs: with sparse
PK, pk.nca() estimates them as the sparse AUClast or AUMClast (see
pk.calc.auclast_sparse()) plus the extrapolation from the mean
concentration at tlast with the lambda.z of the mean profile, with the
standard error of Yuan (1993) and its extension to the AUMC. The
sparse_lambda_z_se option of PKNCA.options() chooses whether the standard
error adds the uncertainty of lambda.z with the delta method ("delta",
the default) or treats it as known ("none", Yuan's method); see
vignette("v24-sparse-auc-to-infinity").
pk.calc.aucinf.obs_sparse( conc, time, subject, lambda.z, lambda.z.time.first, lambda.z.time.last, lambda.z.n.points, ..., options = list() ) pk.calc.aumcinf.obs_sparse( conc, time, subject, lambda.z, lambda.z.time.first, lambda.z.time.last, lambda.z.n.points, ..., options = list() )pk.calc.aucinf.obs_sparse( conc, time, subject, lambda.z, lambda.z.time.first, lambda.z.time.last, lambda.z.n.points, ..., options = list() ) pk.calc.aumcinf.obs_sparse( conc, time, subject, lambda.z, lambda.z.time.first, lambda.z.time.last, lambda.z.n.points, ..., options = list() )
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
subject |
Subject identifiers (may be any class; may not be null). A
missing subject marks an imputed concentration (such as the zero that the
|
lambda.z |
The elimination rate of the mean profile |
lambda.z.time.first, lambda.z.time.last, lambda.z.n.points
|
The first and last time and the number of points of the half-life fit to the mean profile |
... |
For functions other than |
options |
List of changes to the default PKNCA options (see
|
A data.frame with the point estimate, its standard error, and the
degrees of freedom, named for the parameter (aucinf.obs, aucinf.obs_se,
and aucinf.obs_df, or the aumcinf.obs equivalents)
pk.calc.aumcinf.obs_sparse(): Sparse AUMCinf,obs
Yuan J. Estimation of variance for AUC in animal studies. Journal of Pharmaceutical Sciences. 1993;82(7):761-763. doi:10.1002/jps.2600820718
Other Sparse Methods:
as_sparse_pk(),
pk.calc.aucivlast_sparse(),
pk.calc.auclast_sparse(),
pk.calc.sparse_auc(),
pk.calc.sparse_aumc(),
sparse_auc_weight_linear(),
sparse_bootstrap(),
sparse_mean(),
summary.PKNCAresults_sparse_bootstrap()
These are the FUN_sparse of aucivlast, aucivall, aucivinf.obs,
aumcivlast, aumcivall, and aumcivinf.obs: with sparse PK and no
concentration at time 0, is
back-extrapolated from the mean profile with the methods of pk.calc.c0()
(log-linear from the first two means when the profile declines), and the
area from time 0 to the first sample is added to the sparse AUC (see
pk.calc.auclast_sparse(), pk.calc.sparse_auc() for AUCall, and
pk.calc.aucinf.obs_sparse()). is
a function of the means, so its uncertainty is added to the standard error
with the delta method. With the linear trapezoidal rule, the AUMC from time
0 to the first sample does not depend on . A nonzero concentration
measured at time 0 is used as ; a zero there, measured or imputed
(as by the start_conc0 imputation), is not, as for pk.calc.c0().
pk.calc.aucivlast_sparse(conc, time, subject, ..., options = list()) pk.calc.aucivall_sparse(conc, time, subject, ..., options = list()) pk.calc.aucivinf.obs_sparse( conc, time, subject, lambda.z, lambda.z.time.first, lambda.z.time.last, lambda.z.n.points, ..., options = list() ) pk.calc.aumcivlast_sparse(conc, time, subject, ..., options = list()) pk.calc.aumcivall_sparse(conc, time, subject, ..., options = list()) pk.calc.aumcivinf.obs_sparse( conc, time, subject, lambda.z, lambda.z.time.first, lambda.z.time.last, lambda.z.n.points, ..., options = list() )pk.calc.aucivlast_sparse(conc, time, subject, ..., options = list()) pk.calc.aucivall_sparse(conc, time, subject, ..., options = list()) pk.calc.aucivinf.obs_sparse( conc, time, subject, lambda.z, lambda.z.time.first, lambda.z.time.last, lambda.z.n.points, ..., options = list() ) pk.calc.aumcivlast_sparse(conc, time, subject, ..., options = list()) pk.calc.aumcivall_sparse(conc, time, subject, ..., options = list()) pk.calc.aumcivinf.obs_sparse( conc, time, subject, lambda.z, lambda.z.time.first, lambda.z.time.last, lambda.z.n.points, ..., options = list() )
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
subject |
Subject identifiers (may be any class; may not be null). A
missing subject marks an imputed concentration (such as the zero that the
|
... |
For functions other than |
options |
List of changes to the default PKNCA options (see
|
lambda.z |
The elimination rate of the mean profile |
lambda.z.time.first, lambda.z.time.last, lambda.z.n.points
|
The first and last time and the number of points of the half-life fit to the mean profile |
A data.frame with the point estimate, its standard error, and the
degrees of freedom, named for the parameter (for example, aucivlast,
aucivlast_se, and aucivlast_df)
pk.calc.aucivall_sparse(): Sparse AUCall for IV bolus dosing
pk.calc.aucivinf.obs_sparse(): Sparse AUCinf,obs for IV bolus dosing
pk.calc.aumcivlast_sparse(): Sparse AUMClast for IV bolus dosing
pk.calc.aumcivall_sparse(): Sparse AUMCall for IV bolus dosing
pk.calc.aumcivinf.obs_sparse(): Sparse AUMCinf,obs for IV bolus dosing
Other Sparse Methods:
as_sparse_pk(),
pk.calc.aucinf.obs_sparse(),
pk.calc.auclast_sparse(),
pk.calc.sparse_auc(),
pk.calc.sparse_aumc(),
sparse_auc_weight_linear(),
sparse_bootstrap(),
sparse_mean(),
summary.PKNCAresults_sparse_bootstrap()
These are the FUN_sparse of auclast, aumclast, aucall, and
aumcall: with sparse PK, pk.nca() estimates those parameters from the
pooled individual samples with the Bailer point estimate and the
Nedelman-Jia/Holder standard error rather than integrating the
arithmetic-mean profile. They wrap pk.calc.sparse_auc() and
pk.calc.sparse_aumc() (with auc.type = "AUClast" or "AUCall"),
reporting the results under the unified parameter names. AUCall adds the
triangle from tlast to the next time, whose mean is zero.
pk.calc.auclast_sparse(conc, time, subject, ..., options = list()) pk.calc.aumclast_sparse(conc, time, subject, ..., options = list()) pk.calc.aucall_sparse(conc, time, subject, ..., options = list()) pk.calc.aumcall_sparse(conc, time, subject, ..., options = list())pk.calc.auclast_sparse(conc, time, subject, ..., options = list()) pk.calc.aumclast_sparse(conc, time, subject, ..., options = list()) pk.calc.aucall_sparse(conc, time, subject, ..., options = list()) pk.calc.aumcall_sparse(conc, time, subject, ..., options = list())
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
subject |
Subject identifiers (may be any class; may not be null). A
missing subject marks an imputed concentration (such as the zero that the
|
... |
For functions other than |
options |
List of changes to the default PKNCA options (see
|
The sparse variance theory is defined for the linear trapezoidal
rule only, so these ignore the auc.method option; pk.nca() says so when
the option is set to anything else.
A data.frame with the point estimate, its standard error, and the
degrees of freedom, named for the parameter (for example, auclast,
auclast_se, and auclast_df)
pk.calc.aumclast_sparse(): Sparse AUMClast
pk.calc.aucall_sparse(): Sparse AUCall
pk.calc.aumcall_sparse(): Sparse AUMCall
Other Sparse Methods:
as_sparse_pk(),
pk.calc.aucinf.obs_sparse(),
pk.calc.aucivlast_sparse(),
pk.calc.sparse_auc(),
pk.calc.sparse_aumc(),
sparse_auc_weight_linear(),
sparse_bootstrap(),
sparse_mean(),
summary.PKNCAresults_sparse_bootstrap()
Calculate the AUC percent extrapolated
pk.calc.aucpext(auclast, aucinf)pk.calc.aucpext(auclast, aucinf)
auclast |
the area under the curve from time 0 to the last measurement above the limit of quantification |
aucinf |
the area under the curve from time 0 to infinity |
aucpext is 100*(1-auclast/aucinf).
The numeric value of the AUC percent extrapolated or NA_real_ if
any of the following are true is.na(aucinf), is.na(auclast),
aucinf <= 0, or auclast <= 0.
Other Half-life and elimination:
adj.r.squared(),
pk.calc.half.life(),
pk.calc.thalf.eff()
Compute the area under the curve (AUC) and the area under the moment curve (AUMC) for pharmacokinetic (PK) data. AUC and AUMC are used for many purposes when analyzing PK in drug development.
pk.calc.auxc( conc, time, interval = c(0, Inf), clast = pk.calc.clast.obs(conc, time, check = FALSE), lambda.z = NA, auc.type = c("AUClast", "AUCinf", "AUCall"), options = list(), method = NULL, conc.blq = NULL, conc.na = NULL, check = TRUE, fun_linear, fun_log, fun_inf ) pk.calc.auc(conc, time, ..., options = list()) pk.calc.auc.last(conc, time, ..., options = list()) pk.calc.auc.inf(conc, time, ..., options = list(), lambda.z) pk.calc.auc.inf.obs(conc, time, clast.obs, ..., options = list(), lambda.z) pk.calc.auc.inf.pred(conc, time, clast.pred, ..., options = list(), lambda.z) pk.calc.auc.all(conc, time, ..., options = list()) pk.calc.aumc(conc, time, ..., options = list()) pk.calc.aumc.last(conc, time, ..., options = list()) pk.calc.aumc.inf(conc, time, ..., options = list(), lambda.z) pk.calc.aumc.inf.obs(conc, time, clast.obs, ..., options = list(), lambda.z) pk.calc.aumc.inf.pred(conc, time, clast.pred, ..., options = list(), lambda.z) pk.calc.aumc.all(conc, time, ..., options = list())pk.calc.auxc( conc, time, interval = c(0, Inf), clast = pk.calc.clast.obs(conc, time, check = FALSE), lambda.z = NA, auc.type = c("AUClast", "AUCinf", "AUCall"), options = list(), method = NULL, conc.blq = NULL, conc.na = NULL, check = TRUE, fun_linear, fun_log, fun_inf ) pk.calc.auc(conc, time, ..., options = list()) pk.calc.auc.last(conc, time, ..., options = list()) pk.calc.auc.inf(conc, time, ..., options = list(), lambda.z) pk.calc.auc.inf.obs(conc, time, clast.obs, ..., options = list(), lambda.z) pk.calc.auc.inf.pred(conc, time, clast.pred, ..., options = list(), lambda.z) pk.calc.auc.all(conc, time, ..., options = list()) pk.calc.aumc(conc, time, ..., options = list()) pk.calc.aumc.last(conc, time, ..., options = list()) pk.calc.aumc.inf(conc, time, ..., options = list(), lambda.z) pk.calc.aumc.inf.obs(conc, time, clast.obs, ..., options = list(), lambda.z) pk.calc.aumc.inf.pred(conc, time, clast.pred, ..., options = list(), lambda.z) pk.calc.aumc.all(conc, time, ..., options = list())
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
interval |
Numeric vector of two numbers for the start and end time of integration |
clast, clast.obs, clast.pred
|
The last concentration above the limit of quantification; this is used for AUCinf calculations. If provided as clast.obs (observed clast value, default), AUCinf is AUCinf,obs. If provided as clast.pred, AUCinf is AUCinf,pred. |
lambda.z |
The elimination rate (in units of inverse time) for extrapolation |
auc.type |
The type of AUC to compute. Choices are 'AUCinf', 'AUClast', and 'AUCall'. |
options |
List of changes to the default PKNCA options (see
|
method |
The method for integration (one of 'lin up/log down', 'lin-log', or 'linear') |
conc.blq |
How to handle a BLQ value that is between above LOQ values? See details for description. |
conc.na |
How to handle NA concentrations. (See |
check |
Run |
fun_linear |
The function to use for integration of the linear part of the curve (not required for AUC or AUMC functions) |
fun_log |
The function to use for integration of the logarithmic part of the curve (if log integration is used; not required for AUC or AUMC functions) |
fun_inf |
The function to use for extrapolation from the final measurement to infinite time (not required for AUC or AUMC functions). |
... |
For functions other than |
pk.calc.auc.last is simply a shortcut setting the interval
parameter to c(0, "last").
Extrapolation beyond Clast occurs using the half-life and Clast,obs; Clast,pred is not yet supported.
If all conc input are zero, then the AU(M)C is zero.
You probably do not want to call pk.calc.auxc(). Usually, you will call
one of the other functions for calculating AUC like pk.calc.auc.last(),
pk.calc.auc.inf.obs(), etc.
A numeric value for the AU(M)C.
pk.calc.auc(): Compute the area under the curve
pk.calc.auc.last(): Compute the AUClast.
pk.calc.auc.inf(): Compute the AUCinf
pk.calc.auc.inf.obs(): Compute the AUCinf with the observed Clast.
pk.calc.auc.inf.pred(): Compute the AUCinf with the predicted Clast.
pk.calc.auc.all(): Compute the AUCall.
pk.calc.aumc(): Compute the area under the moment curve
pk.calc.aumc.last(): Compute the AUMClast.
pk.calc.aumc.inf(): Compute the AUMCinf
pk.calc.aumc.inf.obs(): Compute the AUMCinf with the observed Clast.
pk.calc.aumc.inf.pred(): Compute the AUMCinf with the predicted Clast.
pk.calc.aumc.all(): Compute the AUMCall.
Gabrielsson J, Weiner D. "Section 2.8.1 Computation methods - Linear trapezoidal rule." Pharmacokinetic & Pharmacodynamic Data Analysis: Concepts and Applications, 4th Edition. Stockholm, Sweden: Swedish Pharmaceutical Press, 2000. 162-4.
Gabrielsson J, Weiner D. "Section 2.8.3 Computation methods - Log-linear trapezoidal rule." Pharmacokinetic & Pharmacodynamic Data Analysis: Concepts and Applications, 4th Edition. Stockholm, Sweden: Swedish Pharmaceutical Press, 2000. 164-7.
Other AUC calculations:
pk.calc.auxcint(),
pk.calc.auxciv()
myconc <- c(0, 1, 2, 1, 0.5, 0.25, 0) mytime <- c(0, 1, 2, 3, 4, 5, 6) pk.calc.auc(myconc, mytime, interval=c(0, 6)) pk.calc.auc(myconc, mytime, interval=c(0, Inf))myconc <- c(0, 1, 2, 1, 0.5, 0.25, 0) mytime <- c(0, 1, 2, 3, 4, 5, 6) pk.calc.auc(myconc, mytime, interval=c(0, 6)) pk.calc.auc(myconc, mytime, interval=c(0, Inf))
Calculates AUC or AUMC over a given interval, optionally interpolating or extrapolating concentrations.
pk.calc.auxcint( conc, time, interval = NULL, start = NULL, end = NULL, clast = pk.calc.clast.obs(conc, time), lambda.z = NA, time.dose = NULL, route = "extravascular", duration.dose = 0, auc.type = c("AUClast", "AUCinf", "AUCall"), options = list(), method = NULL, conc.blq = NULL, conc.na = NULL, check = TRUE, fun_linear, fun_log, fun_inf, ... ) pk.calc.aucint(conc, time, ..., options = list()) pk.calc.aucint.last( conc, time, start = NULL, end = NULL, time.dose, route = "extravascular", duration.dose = 0, ..., options = list() ) pk.calc.aucint.all( conc, time, start = NULL, end = NULL, time.dose, route = "extravascular", duration.dose = 0, ..., options = list() ) pk.calc.aucint.inf.obs( conc, time, start = NULL, end = NULL, time.dose, lambda.z, clast.obs, route = "extravascular", duration.dose = 0, ..., options = list() ) pk.calc.aucint.inf.pred( conc, time, start = NULL, end = NULL, time.dose, lambda.z, clast.pred, route = "extravascular", duration.dose = 0, ..., options = list() ) pk.calc.aumcint(conc, time, ..., options = list()) pk.calc.aumcint.last( conc, time, start = NULL, end = NULL, time.dose, route = "extravascular", duration.dose = 0, ..., options = list() ) pk.calc.aumcint.all( conc, time, start = NULL, end = NULL, time.dose, route = "extravascular", duration.dose = 0, ..., options = list() ) pk.calc.aumcint.inf.obs( conc, time, start = NULL, end = NULL, time.dose, lambda.z, clast.obs, route = "extravascular", duration.dose = 0, ..., options = list() ) pk.calc.aumcint.inf.pred( conc, time, start = NULL, end = NULL, time.dose, lambda.z, clast.pred, route = "extravascular", duration.dose = 0, ..., options = list() )pk.calc.auxcint( conc, time, interval = NULL, start = NULL, end = NULL, clast = pk.calc.clast.obs(conc, time), lambda.z = NA, time.dose = NULL, route = "extravascular", duration.dose = 0, auc.type = c("AUClast", "AUCinf", "AUCall"), options = list(), method = NULL, conc.blq = NULL, conc.na = NULL, check = TRUE, fun_linear, fun_log, fun_inf, ... ) pk.calc.aucint(conc, time, ..., options = list()) pk.calc.aucint.last( conc, time, start = NULL, end = NULL, time.dose, route = "extravascular", duration.dose = 0, ..., options = list() ) pk.calc.aucint.all( conc, time, start = NULL, end = NULL, time.dose, route = "extravascular", duration.dose = 0, ..., options = list() ) pk.calc.aucint.inf.obs( conc, time, start = NULL, end = NULL, time.dose, lambda.z, clast.obs, route = "extravascular", duration.dose = 0, ..., options = list() ) pk.calc.aucint.inf.pred( conc, time, start = NULL, end = NULL, time.dose, lambda.z, clast.pred, route = "extravascular", duration.dose = 0, ..., options = list() ) pk.calc.aumcint(conc, time, ..., options = list()) pk.calc.aumcint.last( conc, time, start = NULL, end = NULL, time.dose, route = "extravascular", duration.dose = 0, ..., options = list() ) pk.calc.aumcint.all( conc, time, start = NULL, end = NULL, time.dose, route = "extravascular", duration.dose = 0, ..., options = list() ) pk.calc.aumcint.inf.obs( conc, time, start = NULL, end = NULL, time.dose, lambda.z, clast.obs, route = "extravascular", duration.dose = 0, ..., options = list() ) pk.calc.aumcint.inf.pred( conc, time, start = NULL, end = NULL, time.dose, lambda.z, clast.pred, route = "extravascular", duration.dose = 0, ..., options = list() )
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
interval |
Numeric vector of two numbers for the start and end time of integration |
start |
The start time of the interval |
end |
The end time of the interval |
clast, clast.obs, clast.pred
|
The last concentration above the limit of
quantification; this is used for AUCinf calculations. If provided as
|
lambda.z |
The elimination rate (in units of inverse time) for extrapolation |
time.dose, route, duration.dose
|
The time of doses, route of
administration, and duration of dose used with interpolation and
extrapolation of concentration data (see |
auc.type |
The type of AUC to compute. Choices are 'AUCinf', 'AUClast', and 'AUCall'. |
options |
List of changes to the default PKNCA options (see
|
method |
The method for integration (one of 'lin up/log down', 'lin-log', or 'linear') |
conc.blq |
How to handle a BLQ value that is between above LOQ values? See details for description. |
conc.na |
How to handle NA concentrations. (See |
check |
Run |
fun_linear, fun_log, fun_inf
|
Integration functions for linear, logarithmic, and infinite extrapolation methods. |
... |
Additional arguments passed to |
The AUXC for an interval of time as a number
pk.calc.aucint(): Calculate AUC over an interval
pk.calc.aucint.last(): Interpolate or extrapolate concentrations for
AUClast
pk.calc.aucint.all(): Interpolate or extrapolate concentrations for
AUCall
pk.calc.aucint.inf.obs(): Interpolate or extrapolate concentrations for
AUCinf.obs
pk.calc.aucint.inf.pred(): Interpolate or extrapolate concentrations for
AUCinf.pred
pk.calc.aumcint(): Calculate AUMC over an interval
pk.calc.aumcint.last(): Interpolate or extrapolate concentrations for
AUMClast
pk.calc.aumcint.all(): Interpolate or extrapolate concentrations for
AUMCall
pk.calc.aumcint.inf.obs(): Interpolate or extrapolate concentrations for
AUMCinf.obs
pk.calc.aumcint.inf.pred(): Interpolate or extrapolate concentrations for
AUMCinf.pred
When dose times are given, the concentrations used to extrapolate the
profile being integrated, if extrapolation is required, end at the first
dose at or after end: a concentration measured after that dose is
affected by the dose and is neither integrated nor used for
interpolation/extrapolation into this interval. Concentrations from before
the interval are used to estimate the concentration at start, and that
estimate does not interpolate across a dose either (see
interp.extrap.conc.dose()).
Only start and end are estimated. A dose within the interval is
integrated across using the concentrations measured on either side of it,
because the interval asks for the profiles on both sides of that dose to be
integrated together.
The region of the interval after the last measurable concentration is handled the same way as the matching AUC parameter:
AUClastcontributes zero.
AUCallcontributes the triangle from clast to the first
below-the-limit-of-quantification measurement and zero after that.
AUCinfis extrapolated with lambda.z (in other words, with the
half-life), always using the logarithmic trapezoidal rule to align with
the exponential decay that the half-life describes. When lambda.z is
not estimable and the interval is finite, AUCall is used instead.
When the interval ends at or before Tlast, no extrapolation happens and
lambda.z is not used at all. The extrapolation that was used is reported
in the method (PPANMETH) column.
PKNCA.options(), interp.extrap.conc.dose()
Other AUC calculations:
pk.calc.auxc(),
pk.calc.auxciv()
Other AUMC calculations:
pk.calc.auxciv()
Calculates AUC or AUMC for intravenous dosing, with optional back-extrapolation to C0.
pk.calc.auxciv( conc, time, c0, auxc, fun_auxc_last, fun_auxc, auc.type = NULL, lambda.z = NA, clast = NA, ..., options = list(), check = TRUE ) pk.calc.auciv( conc, time, c0, auc, auc.type = NULL, lambda.z = NA, clast = NA, ..., options = list(), check = TRUE ) pk.calc.auciv_pbext( conc, time, auc, auciv, ..., options = list(), check = TRUE ) pk.calc.aumciv( conc, time, c0, aumc, auc.type = NULL, lambda.z = NA, clast = NA, ..., options = list(), check = TRUE )pk.calc.auxciv( conc, time, c0, auxc, fun_auxc_last, fun_auxc, auc.type = NULL, lambda.z = NA, clast = NA, ..., options = list(), check = TRUE ) pk.calc.auciv( conc, time, c0, auc, auc.type = NULL, lambda.z = NA, clast = NA, ..., options = list(), check = TRUE ) pk.calc.auciv_pbext( conc, time, auc, auciv, ..., options = list(), check = TRUE ) pk.calc.aumciv( conc, time, c0, aumc, auc.type = NULL, lambda.z = NA, clast = NA, ..., options = list(), check = TRUE )
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
c0 |
The concentration at time 0, typically calculated using |
auxc |
The AUXC calculated using |
fun_auxc_last |
Function to calculate the AUXC for the last interval
(e.g., |
fun_auxc |
Function to calculate the AUXC over the full interval when
|
auc.type |
The type of AUXC for |
lambda.z |
The elimination rate (in units of inverse time) for extrapolation |
clast |
The last concentration above the limit of quantification, used
by |
... |
For functions other than |
options |
List of changes to the default PKNCA options (see
|
check |
Run |
auc |
The AUC calculated without C0 back-extrapolation |
auciv |
The AUC calculated using |
aumc |
The AUMC calculated using |
The AUXC for intravenous (IV) dosing extrapolates the AUXC back from the first
measurement to time 0 using c0 and the AUXC calculated by another method
(e.g., auclast or aumclast).
How the calculation proceeds depends on what is measured at time = 0:
time = 0
The AUXC between time = 0
and the next time point is calculated with the measured concentration
(auxc_first) and with c0 (auxc_second). The final AUXC is
auxc + auxc_second - auxc_first.
time = 0 and auxc was calculatedauxc comes
from a method that extrapolates back to time = 0 with conc.origin
(zero; the aucint family), so that segment is replaced by the one using
c0 in the same way.
time = 0 and auxc is NA
auxc is NA
because an AUXC may not start before the first measurement. c0 supplies
that measurement, so the AUXC is calculated here from c0 and the
measured data using fun_auxc and auc.type.
The calculation for back-extrapolation is 100*(1 - auc/auciv). It
requires a measured concentration at time 0; without one, auc does not
describe the observed part of auciv (it either cannot be calculated or,
for the aucint family, already extrapolates back to time 0 with
conc.origin), so NA is returned.
The AUXC calculated using c0
pk.calc.auciv_pctbackextrap: The AUC percent back-extrapolated
pk.calc.auciv(): Calculate AUC for intravenous dosing with C0 back-extrapolation
pk.calc.auciv_pbext(): Calculate the percent back-extrapolated AUC for IV
administration
pk.calc.aumciv(): Calculate AUMC for intravenous dosing with C0 back-extrapolation
Other AUC calculations:
pk.calc.auxc(),
pk.calc.auxcint()
Other AUMC calculations:
pk.calc.auxcint()
Estimate the concentration at dosing time for an IV bolus dose.
pk.calc.c0( conc, time, time.dose = 0, method = c("c0", "logslope", "c1", "cmin", "set0"), check = TRUE ) pk.calc.c0.method.logslope(conc, time, time.dose = 0, check = TRUE) pk.calc.c0.method.c0(conc, time, time.dose = 0, check = TRUE) pk.calc.c0.method.c1(conc, time, time.dose = 0, check = TRUE) pk.calc.c0.method.set0(conc, time, time.dose = 0, check = TRUE) pk.calc.c0.method.cmin(conc, time, time.dose = 0, check = TRUE)pk.calc.c0( conc, time, time.dose = 0, method = c("c0", "logslope", "c1", "cmin", "set0"), check = TRUE ) pk.calc.c0.method.logslope(conc, time, time.dose = 0, check = TRUE) pk.calc.c0.method.c0(conc, time, time.dose = 0, check = TRUE) pk.calc.c0.method.c1(conc, time, time.dose = 0, check = TRUE) pk.calc.c0.method.set0(conc, time, time.dose = 0, check = TRUE) pk.calc.c0.method.cmin(conc, time, time.dose = 0, check = TRUE)
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
time.dose |
The time when dosing occurred |
method |
The order of methods to test (see details) |
check |
Run |
Methods available for interpolation are below, and each has its own specific function.
c0If the observed conc at time.dose is nonzero, return that. This method should usually be used first for single-dose IV bolus data in case nominal time zero is measured.
logslopeCompute the semilog line between the first two measured times, and use that line to extrapolate backward to time.dose
c1Use the first point after time.dose
cminSet c0 to cmin during the interval. This method should usually be used for multiple-dose oral data and IV infusion data.
set0Set c0 to zero (regardless of any other data). This method should usually be used first for single-dose oral data.
The estimated concentration at time 0.
pk.calc.c0.method.logslope(): Semilog regress the first and second points
after time.dose. This method will return NA if the second
conc after time.dose is 0 or greater than the first.
pk.calc.c0.method.c0(): Use C0 = conc[time %in% time.dose] if it is
nonzero.
pk.calc.c0.method.c1(): Use C0 = C1.
pk.calc.c0.method.set0(): Use C0 = 0 (typically used for single dose oral and
IV infusion)
pk.calc.c0.method.cmin(): Use C0 = Cmin (typically used for multiple dose oral
and IV infusion but not IV bolus)
Other NCA parameters for concentrations during the intervals:
pk.calc.cav(),
pk.calc.ceoi(),
pk.calc.clast.obs(),
pk.calc.cmax(),
pk.calc.count_conc(),
pk.calc.ctrough()
Calculate the average concentration during an interval.
pk.calc.cav(auc, start, end)pk.calc.cav(auc, start, end)
auc |
The area under the curve during the interval |
start |
The start time of the interval |
end |
The end time of the interval |
cav is auc/(end-start).
The Cav (average concentration during the interval)
Other NCA parameters for concentrations during the intervals:
pk.calc.c0(),
pk.calc.ceoi(),
pk.calc.clast.obs(),
pk.calc.cmax(),
pk.calc.count_conc(),
pk.calc.ctrough()
Determine the concentration at the end of infusion
pk.calc.ceoi(conc, time, duration.dose = NA, check = TRUE)pk.calc.ceoi(conc, time, duration.dose = NA, check = TRUE)
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
duration.dose |
The duration for the dosing administration (typically from IV infusion) |
check |
Run |
The concentration at the end of the infusion, NA if
duration.dose is NA, or NA if all time != duration.dose
Other NCA parameters for concentrations during the intervals:
pk.calc.c0(),
pk.calc.cav(),
pk.calc.clast.obs(),
pk.calc.cmax(),
pk.calc.count_conc(),
pk.calc.ctrough()
Calculate the (observed oral) clearance
pk.calc.cl(dose, auc)pk.calc.cl(dose, auc)
dose |
the dose administered |
auc |
The area under the concentration-time curve. |
cl is dose/auc.
If dose is the same length as the other inputs, then the output
will be the same length as all of the inputs; the function assumes that you
are calculating for multiple intervals simultaneously. If the inputs other
than dose are scalars and dose is a vector, then the function assumes
multiple doses were given in a single interval, and the sum of the doses
will be used for the calculation.
the numeric value of the total (CL) or observed oral clearance (CL/F)
Gabrielsson J, Weiner D. "Section 2.5.1 Derivation of clearance." Pharmacokinetic & Pharmacodynamic Data Analysis: Concepts and Applications, 4th Edition. Stockholm, Sweden: Swedish Pharmaceutical Press, 2000. 86-7.
Other Clearance and volume parameters:
pk.calc.kel(),
pk.calc.vz()
If all concentrations are missing, NA_real_ is returned. If all
concentrations are zero (below the limit of quantification) or missing, zero
is returned. If Tlast is NA (due to no non-missing above LOQ measurements),
this will return NA_real_.
pk.calc.clast.obs(conc, time, check = TRUE)pk.calc.clast.obs(conc, time, check = TRUE)
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
check |
Run |
The last observed concentration above the LOQ
Other NCA parameters for concentrations during the intervals:
pk.calc.c0(),
pk.calc.cav(),
pk.calc.ceoi(),
pk.calc.cmax(),
pk.calc.count_conc(),
pk.calc.ctrough()
Calculate renal clearance
pk.calc.clr(ae, auc)pk.calc.clr(ae, auc)
ae |
The amount excreted in urine (as a numeric scalar or vector) |
auc |
The area under the curve (as a numeric scalar or vector) |
clr is sum(ae)/auc.
The units for the ae and auc should match such that ae/auc has
units of volume/time.
The renal clearance as a number
Other Urine/Excretion parameters:
pk.calc.ae(),
pk.calc.erint(),
pk.calc.erlst(),
pk.calc.ermax(),
pk.calc.ertlst(),
pk.calc.ertmax(),
pk.calc.fe(),
pk.calc.volpk()
Determine maximum observed PK concentration
pk.calc.cmax(conc, check = TRUE) pk.calc.cmin(conc, check = TRUE)pk.calc.cmax(conc, check = TRUE) pk.calc.cmin(conc, check = TRUE)
conc |
Measured concentrations |
check |
Run |
a number for the maximum concentration or NA if all concentrations are missing
pk.calc.cmin(): Determine the minimum observed PK
concentration
Other NCA parameters for concentrations during the intervals:
pk.calc.c0(),
pk.calc.cav(),
pk.calc.ceoi(),
pk.calc.clast.obs(),
pk.calc.count_conc(),
pk.calc.ctrough()
conc_data <- Theoph[Theoph$Subject == 1,] pk.calc.cmin(conc_data$conc)conc_data <- Theoph[Theoph$Subject == 1,] pk.calc.cmin(conc_data$conc)
count_conc and count_conc_measured are typically used for quality control
on the data to ensure that there are a sufficient number of non-missing
samples for a calculation and to ensure that data are consistent between
individuals.
pk.calc.count_conc(conc, check = TRUE) pk.calc.count_conc_measured(conc, check = TRUE)pk.calc.count_conc(conc, check = TRUE) pk.calc.count_conc_measured(conc, check = TRUE)
conc |
Measured concentrations |
check |
Run |
a count of the non-missing concentrations (0 if all concentrations are missing)
a count of the non-missing, measured (not below or above the limit of quantification) concentrations (0 if all concentrations are missing). "Measured" here means above the limit of quantification; an imputed concentration above it is counted (see the "Imputed concentrations" section).
pk.calc.count_conc_measured(): Count the number of concentration measurements
that are not missing, above, or below the limit of quantification in an
interval
Both counts are taken after imputation, and neither distinguishes an imputed
concentration from a measured one. count_conc counts every non-missing
concentration, so any imputation that adds a point increases it.
count_conc_measured counts concentrations above the limit of
quantification, so whether an imputed point is counted depends on its value
rather than on its being imputed: the zero added by
PKNCA_impute_method_start_conc0() is not counted, while the concentration
carried to the start time by PKNCA_impute_method_start_predose() and the
minimum added by PKNCA_impute_method_start_cmin() are.
To count only measured samples, calculate the counts in an interval with no imputation.
Other NCA parameters for concentrations during the intervals:
pk.calc.c0(),
pk.calc.cav(),
pk.calc.ceoi(),
pk.calc.clast.obs(),
pk.calc.cmax(),
pk.calc.ctrough()
Determine the trough (end of interval) concentration
pk.calc.ctrough(conc, time, end) pk.calc.cstart(conc, time, start)pk.calc.ctrough(conc, time, end) pk.calc.cstart(conc, time, start)
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
end |
The end time of the interval |
start |
The start time of the interval |
The concentration when time == end. If none match, then NA
pk.calc.cstart(): Concentration at the beginning of the interval
Other NCA parameters for concentrations during the intervals:
pk.calc.c0(),
pk.calc.cav(),
pk.calc.ceoi(),
pk.calc.clast.obs(),
pk.calc.cmax(),
pk.calc.count_conc()
Determine the degree of fluctuation
pk.calc.deg.fluc(cmax, cmin, cav) pk.calc.swing(cmax, cmin)pk.calc.deg.fluc(cmax, cmin, cav) pk.calc.swing(cmax, cmin)
cmax |
The maximum observed concentration |
cmin |
The minimum observed concentration |
cav |
The average concentration in the interval |
deg.fluc is 100*(cmax - cmin)/cav.
swing is 100*(cmax - cmin)/cmin.
The degree of fluctuation around the average concentration.
The swing above the minimum concentration. If cmin is zero, then
the result is infinity.
pk.calc.swing(): PK swing
Other Multiple-dose PK parameters:
pk.calc.ptr()
Determine dose normalized NCA parameter
pk.calc.dn(parameter, dose)pk.calc.dn(parameter, dose)
parameter |
Parameter to dose normalize |
dose |
Dose in units compatible with the area under the curve |
a number for dose normalized AUC
pk.calc.dn(90, 10)pk.calc.dn(90, 10)
Calculate the excretion rate over the interval
pk.calc.erint(ae, start, end)pk.calc.erint(ae, start, end)
ae |
The amount excreted during the interval (see |
start |
The start time of the interval |
end |
The end time of the interval |
The excretion rate is the amount recovered during the interval
divided by the duration of the interval, ae/(end - start). It uses the
interval rather than the sum of the collection durations, so a gap between
collections lowers the rate. An interval ending at infinity has no
duration to divide by and gives NA.
The excretion rate during the interval
Other Urine/Excretion parameters:
pk.calc.ae(),
pk.calc.clr(),
pk.calc.erlst(),
pk.calc.ermax(),
pk.calc.ertlst(),
pk.calc.ertmax(),
pk.calc.fe(),
pk.calc.volpk()
Calculate the last measurable excretion rate
pk.calc.erlst(conc, volume, time, duration.conc, check = TRUE)pk.calc.erlst(conc, volume, time, duration.conc, check = TRUE)
conc |
The concentration in the excreta (e.g., urine or feces) |
volume |
The volume (or mass) of the sample |
time |
The starting time of the collection interval |
duration.conc |
The duration of the collection interval |
check |
Should the concentration data be checked? |
Collections are ordered by their midpoint time, matching
pk.calc.ertlst(), which gives the midpoint time of this same collection.
When no collection has a positive excretion rate, the result is 0.
The last measurable (positive) excretion rate, or NA if not
available
pk.calc.ertlst(), pk.calc.ermax()
Other Urine/Excretion parameters:
pk.calc.ae(),
pk.calc.clr(),
pk.calc.erint(),
pk.calc.ermax(),
pk.calc.ertlst(),
pk.calc.ertmax(),
pk.calc.fe(),
pk.calc.volpk()
Calculate the maximum excretion rate
pk.calc.ermax(conc, volume, time, duration.conc, check = TRUE)pk.calc.ermax(conc, volume, time, duration.conc, check = TRUE)
conc |
The concentration in the excreta (e.g., urine or feces) |
volume |
The volume (or mass) of the sample |
time |
The starting time of the collection interval |
duration.conc |
The duration of the collection interval |
check |
Should the concentration data be checked? |
The maximum excretion rate, or NA if not available
Other Urine/Excretion parameters:
pk.calc.ae(),
pk.calc.clr(),
pk.calc.erint(),
pk.calc.erlst(),
pk.calc.ertlst(),
pk.calc.ertmax(),
pk.calc.fe(),
pk.calc.volpk()
Calculate the midpoint collection time of the last measurable excretion rate
pk.calc.ertlst(conc, volume, time, duration.conc, check = TRUE)pk.calc.ertlst(conc, volume, time, duration.conc, check = TRUE)
conc |
The concentration in the excreta (e.g., urine or feces) |
volume |
The volume (or mass) of the sample |
time |
The starting time of the collection interval |
duration.conc |
The duration of the collection interval |
check |
Should the concentration and time data be checked? |
The midpoint collection time of the last measurable excretion rate, or NA/0 if not available
Other Urine/Excretion parameters:
pk.calc.ae(),
pk.calc.clr(),
pk.calc.erint(),
pk.calc.erlst(),
pk.calc.ermax(),
pk.calc.ertmax(),
pk.calc.fe(),
pk.calc.volpk()
Calculate the midpoint collection time of the maximum excretion rate
pk.calc.ertmax( conc, volume, time, duration.conc, options = list(), check = TRUE, first.tmax = NULL )pk.calc.ertmax( conc, volume, time, duration.conc, options = list(), check = TRUE, first.tmax = NULL )
conc |
The concentration in the excreta (e.g., urine or feces) |
volume |
The volume (or mass) of the sample |
time |
The starting time of the collection interval |
duration.conc |
The duration of the collection interval |
options |
List of changes to the default PKNCA options (see
|
check |
Should the concentration and time data be checked? |
first.tmax |
If TRUE, return the first time of maximum excretion rate; otherwise, return the last |
The midpoint collection time of the maximum excretion rate, or NA if not available
Other Urine/Excretion parameters:
pk.calc.ae(),
pk.calc.clr(),
pk.calc.erint(),
pk.calc.erlst(),
pk.calc.ermax(),
pk.calc.ertlst(),
pk.calc.fe(),
pk.calc.volpk()
Calculate the absolute (or relative) bioavailability
pk.calc.f(dose1, auc1, dose2, auc2)pk.calc.f(dose1, auc1, dose2, auc2)
dose1 |
The dose administered in route or method 1 |
auc1 |
The AUC from 0 to infinity or 0 to tau administered in route or method 1 |
dose2 |
The dose administered in route or method 2 |
auc2 |
The AUC from 0 to infinity or 0 to tau administered in route or method 2 |
f is (auc2/dose2)/(auc1/dose1).
Calculate fraction excreted (typically in urine or feces)
pk.calc.fe(ae, dose)pk.calc.fe(ae, dose)
ae |
The amount excreted (as a numeric scalar or vector) |
dose |
The dose (as a numeric scalar or vector) |
fe is sum(ae)/dose
The units for ae and dose should be the same so that ae/dose
is a unitless fraction.
The fraction of dose excreted
Other Urine/Excretion parameters:
pk.calc.ae(),
pk.calc.clr(),
pk.calc.erint(),
pk.calc.erlst(),
pk.calc.ermax(),
pk.calc.ertlst(),
pk.calc.ertmax(),
pk.calc.volpk()
The terminal elimination half-life is estimated from the final points in the
concentration-time curve using semi-log regression (log(conc)~time, the
"log-linear" method) or Tobit regression ("tobit" method) with automated
selection of the points for calculation (unless manually.selected.points is
TRUE).
pk.calc.half.life( conc, time, tmax, tlast, time.dose = NULL, duration.dose = 0, lloq = NULL, hl_method = c("log-linear", "tobit"), manually.selected.points = FALSE, options = list(), min.hl.points = NULL, max.hl.points = NULL, min.hl.start.time = NULL, adj.r.squared.factor = NULL, r.squared.factor = NULL, tobit_n_points_penalty = NULL, tobit_optim_control = NULL, conc.blq = NULL, conc.na = NULL, first.tmax = NULL, allow.tmax.in.half.life = NULL, check = TRUE )pk.calc.half.life( conc, time, tmax, tlast, time.dose = NULL, duration.dose = 0, lloq = NULL, hl_method = c("log-linear", "tobit"), manually.selected.points = FALSE, options = list(), min.hl.points = NULL, max.hl.points = NULL, min.hl.start.time = NULL, adj.r.squared.factor = NULL, r.squared.factor = NULL, tobit_n_points_penalty = NULL, tobit_optim_control = NULL, conc.blq = NULL, conc.na = NULL, first.tmax = NULL, allow.tmax.in.half.life = NULL, check = TRUE )
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
tmax |
Time of maximum concentration (will be calculated and included in the return data frame if not given) |
tlast |
Time of last concentration above the limit of quantification (will be calculated and included in the return data frame if not given) |
time.dose |
Time of the dose for the current interval (must be the same
length as |
duration.dose |
The duration of the dose administration for the current interval (typically zero for extravascular and intravascular bolus and nonzero for intravascular infusion) |
lloq |
Lower limit of quantification. A scalar or a vector the same
length as |
hl_method |
The method used to estimate the half-life.
|
manually.selected.points |
Have the input points ( |
options |
List of changes to the default PKNCA options (see
|
min.hl.points |
The minimum number of points that must be
included to calculate the half-life. For |
max.hl.points |
The maximum number of points that automatic point
selection may use ( |
min.hl.start.time |
The earliest time at which automatic point
selection may start the half-life: points before it are not used. It is
on the scale of |
adj.r.squared.factor |
The allowance in adjusted r-squared for
adding another point (log-linear method only). Giving it takes
|
r.squared.factor |
The allowance in r-squared for adding another point
(log-linear method only). Giving it takes |
tobit_n_points_penalty |
The penalty exponent on the number of points
for Tobit window selection. See |
tobit_optim_control |
A list of control parameters passed to
|
conc.blq |
How to handle a BLQ value that is between above LOQ values? See details for description. |
conc.na |
How to handle NA concentrations. (See |
first.tmax |
If there is more than one time point with the maximum value (Cmax or ERmax), which time should be selected for Tmax/ERTmax? If 'TRUE', the first will be selected. If not, then the last is considered Tmax/ERTmax. |
allow.tmax.in.half.life |
Allow the concentration point for tmax to be included in the half-life slope calculation. |
check |
Run |
See the "Half-Life Calculation" and "Half-Life Calculation with Tobit Regression" vignettes for more details on the calculation methods.
If manually.selected.points is FALSE (default), the
half-life is calculated by computing the best fit line for all points at or
after tmax (based on the value of allow.tmax.in.half.life).
For hl_method = "log-linear", the best half-life is chosen by the
following rules in order:
At least min.hl.points and at most max.hl.points points included,
the first of them no earlier than min.hl.start.time
A lambda.z > 0 and at the same time the best adjusted r-squared
(within adj.r.squared.factor) or, when adj.r.squared.factor is NA,
the best r-squared (within r.squared.factor)
The one with the most points included
For hl_method = "tobit", BLQ observations are retained and treated as
left-censored. The best window is the one minimizing
tobit_residual * n ^ tobit_n_points_penalty (default: raw tobit_residual)
among windows with lambda.z > 0, at least min.hl.points and at most
max.hl.points above-LLOQ points, and a first point no earlier than
min.hl.start.time. On ties the largest window (most total points) is
preferred.
If manually.selected.points is TRUE, the conc and time data are
used as-is without any form of point selection. When
TRUE, adj.r.squared.factor, r.squared.factor, min.hl.points,
max.hl.points, min.hl.start.time, and allow.tmax.in.half.life are
ignored.
A data frame with one row. Columns depend on hl_method:
Columns returned by both methods:
Time of maximum observed concentration (only included if not given as an input)
Time of last observed concentration above the LOQ (only included if not given as an input)
elimination rate
first time for half-life calculation
last time for half-life calculation
number of points in half-life calculation (all points for Tobit, including BLQ)
Concentration at tlast as predicted by the half-life line
half-life
ratio of the above-LLOQ time span to the half-life
Additional columns for hl_method = "log-linear":
coefficient of determination
adjusted coefficient of determination
correlation between time and log-conc for the half-life points
Additional columns for hl_method = "tobit":
number of BLQ points included in the fit
estimated residual standard deviation from the Tobit fit (on the log-concentration scale)
adjusted Tobit residual (analogous to adjusted r-squared; penalizes smaller windows)
Gabrielsson J, Weiner D. "Section 2.8.4 Strategies for estimation of lambda-z." Pharmacokinetic & Pharmacodynamic Data Analysis: Concepts and Applications, 4th Edition. Stockholm, Sweden: Swedish Pharmaceutical Press, 2000. 167-9.
Other Half-life and elimination:
adj.r.squared(),
pk.calc.aucpext(),
pk.calc.thalf.eff()
Calculate the elimination rate (Kel)
pk.calc.kel(mrt)pk.calc.kel(mrt)
mrt |
the mean residence time |
kel |
is |
the numeric value of the elimination rate
Other Clearance and volume parameters:
pk.calc.cl(),
pk.calc.vz()
Calculate the mean residence time (MRT) for single-dose data or linear multiple-dose data.
pk.calc.mrt(auc, aumc) pk.calc.mrt.iv(auc, aumc, duration.dose) pk.calc.mrt.md(auctau, aumctau, aucinf, tau) pk.calc.mrt.md.iv(auctau, aumctau, aucinf, tau, duration.dose)pk.calc.mrt(auc, aumc) pk.calc.mrt.iv(auc, aumc, duration.dose) pk.calc.mrt.md(auctau, aumctau, aucinf, tau) pk.calc.mrt.md.iv(auctau, aumctau, aucinf, tau, duration.dose)
auc |
the AUC from 0 to infinity or 0 to tau |
aumc |
the AUMC from 0 to infinity or 0 to tau |
duration.dose |
The duration of the dose (usually an infusion duration for an IV infusion) |
auctau |
the AUC from time 0 to the end of the dosing interval (tau). |
aumctau |
the AUMC from time 0 to the end of the dosing interval (tau). |
aucinf |
the AUC from time 0 to infinity (typically using single-dose data) |
tau |
The dosing interval |
mrt is aumc/auc - duration.dose/2 where duration.dose = 0 for oral administration.
mrt.md is aumctau/auctau + tau*(aucinf-auctau)/auctau and should
only be used for multiple dosing with equal intervals between doses.
Note that if aucinf == auctau (as would be the assumption with
linear kinetics), the equation becomes the same as the single-dose MRT.
These are the parameters to use when PK are nonlinear. With linear PK,
MRT and Vss can be measured from a single dose and the single-dose
parameters (mrt.obs, vss.obs, and similar) describe steady state as
well. When PK are nonlinear they do not, so MRT and Vss have to be
measured over a steady-state dosing interval, which is what these
parameters do. The ratio aumctau/auctau on its own (mrt.last over a
dosing interval) is not MRT at steady state and underestimates it
substantially; the tau*(aucinf-auctau)/auctau term accounts for the drug
still in the body at the end of the interval.
Within pk.nca(), tau is detected from the dose times of the group with
find.tau(). When the dosing data hold a single dose (a common
steady-state design where only the profiled dose is recorded), nothing
repeats and nothing can be detected, so give tau as a column of the
interval specification instead; a tau column always takes precedence
over detection. If tau can be neither given nor detected, the parameter
is NA with a warning.
mrt.ivmd is mrt.md less half of the infusion duration, the same
correction that mrt.iv applies to the single-dose MRT. Without it, MRT
and everything derived from it are high by duration.dose/2.
the numeric value of the mean residence time
pk.calc.mrt.iv(): MRT for an IV infusion
pk.calc.mrt.md(): MRT for multiple-dose data with nonlinear kinetics
pk.calc.mrt.md.iv(): MRT for multiple-dose data with nonlinear kinetics
given as an IV infusion
Determine the peak-to-trough ratio
pk.calc.ptr(cmax, ctrough)pk.calc.ptr(cmax, ctrough)
cmax |
The maximum observed concentration |
ctrough |
The last concentration in an interval |
ptr is cmax/ctrough.
The ratio of cmax to ctrough (if ctrough == 0, NA)
Other Multiple-dose PK parameters:
pk.calc.deg.fluc()
Calculate the ratio of a parameter between two intervals
pk.calc.ratio(test, reference)pk.calc.ratio(test, reference)
test |
The parameter value in the current (test) interval |
reference |
The parameter value in the reference interval |
test/reference, or NA where the reference is missing or is not
above zero (a ratio to a zero or negative reference is not interpretable).
pk.calc.ratio(test = 10, reference = 20)pk.calc.ratio(test = 10, reference = 20)
The AUC is calculated as:
pk.calc.sparse_auc( conc, time, subject, method = "linear", auc.type = "AUClast", ..., options = list() ) pk.calc.sparse_auclast(conc, time, subject, ..., options = list())pk.calc.sparse_auc( conc, time, subject, method = "linear", auc.type = "AUClast", ..., options = list() ) pk.calc.sparse_auclast(conc, time, subject, ..., options = list())
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
subject |
Subject identifiers (may be any class; may not be null). A
missing subject marks an imputed concentration (such as the zero that the
|
method |
The method for integration (one of 'lin up/log down', 'lin-log', or 'linear') |
auc.type |
The type of AUC to compute. Choices are 'AUCinf', 'AUClast', and 'AUCall'. |
... |
For functions other than |
options |
List of changes to the default PKNCA options (see
|
Where:
is the estimated area under the concentration-time curve
is the weight applied to the concentration at time i (related to the time which it affects, see sparse_auc_weight_linear())
is the average concentration at time i
pk.calc.sparse_auclast(): Compute the AUClast for sparse PK
Other Sparse Methods:
as_sparse_pk(),
pk.calc.aucinf.obs_sparse(),
pk.calc.aucivlast_sparse(),
pk.calc.auclast_sparse(),
pk.calc.sparse_aumc(),
sparse_auc_weight_linear(),
sparse_bootstrap(),
sparse_mean(),
summary.PKNCAresults_sparse_bootstrap()
The AUMC is calculated as:
pk.calc.sparse_aumc( conc, time, subject, method = "linear", auc.type = "AUClast", ..., options = list() ) pk.calc.sparse_aumclast(conc, time, subject, ..., options = list())pk.calc.sparse_aumc( conc, time, subject, method = "linear", auc.type = "AUClast", ..., options = list() ) pk.calc.sparse_aumclast(conc, time, subject, ..., options = list())
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
subject |
Subject identifiers (may be any class; may not be null). A
missing subject marks an imputed concentration (such as the zero that the
|
method |
The method for integration (one of 'lin up/log down', 'lin-log', or 'linear') |
auc.type |
The type of AUC to compute. Choices are 'AUCinf', 'AUClast', and 'AUCall'. |
... |
For functions other than |
options |
List of changes to the default PKNCA options (see
|
Where:
is the estimated area under the first moment curve
is the weight applied to time i (same as for AUC, see sparse_auc_weight_linear())
is the average of the moment (time × concentration) at time i
A data.frame with columns:
sparse_aumc |
The estimated AUMC |
sparse_aumc_se |
Standard error of the AUMC estimate |
sparse_aumc_df |
Degrees of freedom for the variance estimate |
pk.calc.sparse_aumclast(): Compute the AUMClast for sparse PK
Other Sparse Methods:
as_sparse_pk(),
pk.calc.aucinf.obs_sparse(),
pk.calc.aucivlast_sparse(),
pk.calc.auclast_sparse(),
pk.calc.sparse_auc(),
sparse_auc_weight_linear(),
sparse_bootstrap(),
sparse_mean(),
summary.PKNCAresults_sparse_bootstrap()
Calculate the effective half-life
pk.calc.thalf.eff(mrt)pk.calc.thalf.eff(mrt)
mrt |
the mean residence time to infinity |
thalf.eff is log(2)*mrt.
the numeric value of the effective half-life
Other Half-life and elimination:
adj.r.squared(),
pk.calc.aucpext(),
pk.calc.half.life()
Interpolation is performed aligning with PKNCA.options("auc.method").
Extrapolation outside of the measured times is not yet implemented. The
method may be changed by giving a named method argument, as well.
pk.calc.time_above(conc, time, conc_above, ..., options = list(), check = TRUE)pk.calc.time_above(conc, time, conc_above, ..., options = list(), check = TRUE)
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
conc_above |
The concentration to be above |
... |
Extra arguments. Currently, the only extra argument that is used
is |
options |
List of changes to the default PKNCA options (see
|
check |
Run |
For 'lin up/log down', if clast is above conc_above and there are
concentrations BLQ after that, linear down is used to extrapolate to the BLQ
concentration (equivalent to AUCall).
the time above the given concentration
Determine the observed lag time (time before the first concentration above the limit of quantification or above the first concentration in the interval)
pk.calc.tlag(conc, time)pk.calc.tlag(conc, time)
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
The time associated with the first increasing concentration
Other NCA time parameters:
pk.calc.tlast(),
pk.calc.tmax(),
pk.calc.tmin()
NA will be returned if all conc are NA or 0.
pk.calc.tlast(conc, time, check = TRUE) pk.calc.tfirst(conc, time, check = TRUE)pk.calc.tlast(conc, time, check = TRUE) pk.calc.tfirst(conc, time, check = TRUE)
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
check |
Run |
The time of the last observed concentration measurement
pk.calc.tfirst(): Determine the first concentration above
the limit of quantification.
Other NCA time parameters:
pk.calc.tlag(),
pk.calc.tmax(),
pk.calc.tmin()
Input restrictions are:
the conc and time must be the same length,
the time may have no NAs,
NA will be returned if:
the length of conc and time is 0
all conc is 0 or NA
pk.calc.tmax(conc, time, options = list(), first.tmax = NULL, check = TRUE)pk.calc.tmax(conc, time, options = list(), first.tmax = NULL, check = TRUE)
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
options |
List of changes to the default PKNCA options (see
|
first.tmax |
If there is more than one time point with the maximum value (Cmax or ERmax), which time should be selected for Tmax/ERTmax? If 'TRUE', the first will be selected. If not, then the last is considered Tmax/ERTmax. |
check |
Run |
The time of the maximum concentration
Other NCA time parameters:
pk.calc.tlag(),
pk.calc.tlast(),
pk.calc.tmin()
conc_data <- Theoph[Theoph$Subject == 1,] pk.calc.tmax(conc = conc_data$conc, time = conc_data$Time)conc_data <- Theoph[Theoph$Subject == 1,] pk.calc.tmax(conc = conc_data$conc, time = conc_data$Time)
Input restrictions are:
the conc and time must be the same length,
the time may have no NAs,
NA will be returned if:
the length of conc and time is 0
all conc is NA
pk.calc.tmin(conc, time, options = list(), first.tmin = NULL, check = TRUE)pk.calc.tmin(conc, time, options = list(), first.tmin = NULL, check = TRUE)
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
options |
List of changes to the default PKNCA options (see
|
first.tmin |
If there is more than one time point with the minimum value (Cmin), which time should be selected for Tmin? If 'TRUE', the first will be selected. If not, then the last is considered Tmin. |
check |
Run |
The time of the minimum concentration
Other NCA time parameters:
pk.calc.tlag(),
pk.calc.tlast(),
pk.calc.tmax()
conc_data <- Theoph[Theoph$Subject == 1,] pk.calc.tmin(conc = conc_data$conc, time = conc_data$Time)conc_data <- Theoph[Theoph$Subject == 1,] pk.calc.tmin(conc = conc_data$conc, time = conc_data$Time)
Extract the dose used for calculations
pk.calc.totdose(dose)pk.calc.totdose(dose)
dose |
the dose administered |
The total dose for an interval
Calculate the total urine volume
pk.calc.volpk(volume)pk.calc.volpk(volume)
volume |
The volume (or mass) of the sample |
The sum of urine volumes for the interval
Other Urine/Excretion parameters:
pk.calc.ae(),
pk.calc.clr(),
pk.calc.erint(),
pk.calc.erlst(),
pk.calc.ermax(),
pk.calc.ertlst(),
pk.calc.ertmax(),
pk.calc.fe()
Calculate the terminal volume of distribution (Vz)
pk.calc.vz(cl, lambda.z) pk.calc.vss(cl, mrt)pk.calc.vz(cl, lambda.z) pk.calc.vss(cl, mrt)
cl |
the clearance (or apparent observed clearance) |
lambda.z |
The elimination rate (in units of inverse time) for extrapolation |
mrt |
the mean residence time |
vz is cl/lambda.z.
vss is cl*mrt.
the volume of distribution at steady-state
pk.calc.vss(): Steady-state volume of distribution (Vss)
Other Clearance and volume parameters:
pk.calc.cl(),
pk.calc.kel()
The pk.nca function computes the NCA parameters from a PKNCAdata object.
All options for the calculation and input data are set in prior functions
(PKNCAconc, PKNCAdose, and PKNCAdata). Options for calculations are
set either in PKNCAdata or with the current default options in
PKNCA.options.
pk.nca(data, verbose = FALSE)pk.nca(data, verbose = FALSE)
data |
A PKNCAdata object |
verbose |
Indicate, by |
When performing calculations, all time results are relative to the start of
the interval. For example, if an interval starts at 168 hours, ends at 192
hours, and and the maximum concentration is at 169 hours, tmax=169-168=1.
Data are selected for each interval by the measurement or dose time: rows
with a time at or after the interval start and at or before the interval
end are included (a dose exactly at the interval end is not included in
the interval). For duration data (for example, urine collections or
intravenous infusions), the time is the start of the collection or
administration, and the duration is not considered during selection: a
collection that starts within the interval and ends after the interval end
contributes its full amount to the interval. For the simplest
interpretation of results, align collection start and end times with
interval boundaries.
A PKNCAresults object.
PKNCAdata(), PKNCA.options(), summary.PKNCAresults(),
as.data.frame.PKNCAresults(), exclude()
For one subject/time range, compute all available PK parameters. All the
internal options should be set by PKNCA.options() prior to running. The
only part that changes with a call to this function is the concentration
and time.
pk.nca.interval( conc, time, volume, duration.conc, dose, time.dose, duration.dose, route, conc.group = NULL, time.group = NULL, volume.group = NULL, duration.conc.group = NULL, dose.group = NULL, time.dose.group = NULL, duration.dose.group = NULL, route.group = NULL, conc.sparse = NULL, time.sparse = NULL, conc.sparse.group = NULL, time.sparse.group = NULL, impute_method = NA_character_, include_half.life = NULL, exclude_half.life = NULL, lloq = NULL, subject = NULL, interval, options = list(), timeu = NULL )pk.nca.interval( conc, time, volume, duration.conc, dose, time.dose, duration.dose, route, conc.group = NULL, time.group = NULL, volume.group = NULL, duration.conc.group = NULL, dose.group = NULL, time.dose.group = NULL, duration.dose.group = NULL, route.group = NULL, conc.sparse = NULL, time.sparse = NULL, conc.sparse.group = NULL, time.sparse.group = NULL, impute_method = NA_character_, include_half.life = NULL, exclude_half.life = NULL, lloq = NULL, subject = NULL, interval, options = list(), timeu = NULL )
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
volume, volume.group
|
The volume (or mass) of the concentration measurement for the current interval or all data for the group (typically for urine and fecal measurements) |
duration.conc, duration.conc.group
|
The duration of the concentration measurement for the current interval or all data for the group (typically for urine and fecal measurements) |
dose, dose.group
|
Dose amount (may be a scalar or vector) for the current interval or all data for the group |
time.dose |
Time of the dose for the current interval (must be the same
length as |
duration.dose |
The duration of the dose administration for the current interval (typically zero for extravascular and intravascular bolus and nonzero for intravascular infusion) |
route, route.group
|
The route of dosing for the current interval or all data for the group |
conc.group |
All concentrations measured for the group |
time.group |
Time of all concentrations measured for the group |
time.dose.group |
Time of the dose for all data for the group (must be
the same length as |
duration.dose.group |
The duration of the dose administration for all data for the group (typically zero for extravascular and intravascular bolus and nonzero for intravascular infusion) |
conc.sparse, time.sparse
|
The pooled individual concentrations and their
times for the current interval with sparse PK ( |
conc.sparse.group, time.sparse.group
|
The pooled individual
concentrations and their times for all data for the group with sparse PK.
|
impute_method |
The method to use for imputation as a character string |
exclude_half.life, include_half.life
|
Manual half-life point selection,
given as a logical value per concentration measurement (or, in
|
lloq |
An optional scalar or vector (the same length as |
subject |
Subject identifiers for the pooled sparse samples |
interval |
One row of an interval definition (see
|
options |
List of changes to the default PKNCA options (see
|
timeu |
The time unit of the group's times: |
A data frame with one row per result, with columns PPTESTCD,
PPORRES, PPANMETH, and exclude. Its "sparse" attribute is a logical
vector saying, for each row, whether the parameter that produced it is
registered as a sparse PK parameter.
check.interval.specification()
Compute NCA for multiple intervals
pk.nca.intervals( data_conc, data_dose, data_intervals, options, impute, data_sparse_conc = NULL, verbose = FALSE, timeu = NULL, warning_prefix = "" )pk.nca.intervals( data_conc, data_dose, data_intervals, options, impute, data_sparse_conc = NULL, verbose = FALSE, timeu = NULL, warning_prefix = "" )
data_conc |
A data.frame or tibble with standardized column names as
output from |
data_dose |
A data.frame or tibble with standardized column names as
output from |
data_intervals |
A data.frame or tibble with standardized column names
as output from |
options |
List of changes to the default PKNCA options (see
|
impute |
The column name in |
data_sparse_conc |
For sparse PK, a data.frame or tibble of the pooled
individual samples (including a |
verbose |
Indicate, by |
timeu |
The time unit of the group's times: |
warning_prefix |
The text naming the group, put before each dose regimen warning |
A list with elements "dense" and "sparse", each a data.frame of the NCA results calculated from that concentration representation (or, when no calculation was possible at all, the warning condition saying why)
Compute the time to steady-state (tss)
pk.tss(..., type = c("monoexponential", "stepwise.linear"), check = TRUE)pk.tss(..., type = c("monoexponential", "stepwise.linear"), check = TRUE)
... |
Passed to |
type |
The type of Tss to calculate, either |
check |
A data frame with columns as defined from pk.tss.monoexponential
and/or pk.tss.stepwise.linear.
Other Time to steady-state calculations:
pk.tss.monoexponential(),
pk.tss.stepwise.linear()
Clean up the time to steady-state parameters and return a data frame for use by the tss calculators.
pk.tss.data.prep( conc, time, subject, treatment, subject.dosing, time.dosing, options = list(), conc.blq = NULL, conc.na = NULL, check = TRUE, ... )pk.tss.data.prep( conc, time, subject, treatment, subject.dosing, time.dosing, options = list(), conc.blq = NULL, conc.na = NULL, check = TRUE, ... )
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
subject |
Subject identifiers (used as a random effect in the model) |
treatment |
Treatment description (if missing, all subjects are assumed to be on the same treatment) |
subject.dosing |
Subject number for dosing |
time.dosing |
Time of dosing |
options |
List of changes to the default PKNCA options (see
|
conc.blq |
How to handle a BLQ value that is between above LOQ values? See details for description. |
conc.na |
How to handle NA concentrations. (See |
check |
Run |
... |
Discarded inputs to allow generic calls between tss methods. |
a data frame with columns for concentration, time, subject,
and treatment.
Trough concentrations are selected as concentrations at the time of dosing.
An exponential curve is then fit through the data with a different magnitude
by treatment (as a factor) and a random steady-state concentration and time
to stead-state by subject (see random.effects argument).
pk.tss.monoexponential( ..., tss.fraction = 0.9, output = c("population", "popind", "individual", "single"), check = TRUE, verbose = FALSE )pk.tss.monoexponential( ..., tss.fraction = 0.9, output = c("population", "popind", "individual", "single"), check = TRUE, verbose = FALSE )
... |
|
tss.fraction |
The fraction of steady-state required for calling steady-state |
output |
Which types of outputs should be produced? |
check |
See |
verbose |
Describe models as they are run, show convergence of the model (passed to the nlme function), and additional details while running. |
A scalar float for the first time when steady-state is achieved or
NA if it is not observed.
Maganti, L., Panebianco, D.L. & Maes, A.L. Evaluation of Methods for Estimating Time to Steady State with Examples from Phase 1 Studies. AAPS J 10, 141–147 (2008). https://doi.org/10.1208/s12248-008-9014-y
Other Time to steady-state calculations:
pk.tss(),
pk.tss.stepwise.linear()
This function is not intended to be called directly. Please use
pk.tss.monoexponential.
pk.tss.monoexponential.individual( data, output = c("individual", "single"), verbose = FALSE )pk.tss.monoexponential.individual( data, output = c("individual", "single"), verbose = FALSE )
data |
a data frame as prepared by |
output |
a character vector requesting the output types. |
verbose |
Show verbose output. |
If no model converges, then the tss.monoexponential.single and/or
tss.monoexponential.individual column will be set to NA.
A data frame with either one row (if population output is
provided) or one row per subject (if popind is provided). The columns
will be named tss.monoexponential.population and/or
tss.monoexponential.popind.
This function is not intended to be called directly. Please use
pk.tss.monoexponential.
pk.tss.monoexponential.population( data, output = c("population", "popind"), verbose = FALSE )pk.tss.monoexponential.population( data, output = c("population", "popind"), verbose = FALSE )
data |
a data frame as prepared by |
output |
a character vector requesting the output types. |
verbose |
Show verbose output. |
If no model converges, then the tss.monoexponential.population column will
be set to NA. If the best model does not include a random effect for subject
on Tss then the tss.monoexponential.popind column of the output will be set
to NA.
A data frame with either one row (if population output is
provided) or one row per subject (if popind is provided). The columns
will be named tss.monoexponential.population and/or
tss.monoexponential.popind.
A linear slope is fit through the data to find when it becomes
non-significant. Note that this is less preferred than the
pk.tss.monoexponential due to the fact that with more time or more subjects
the performance of the test changes (see reference).
pk.tss.stepwise.linear( ..., min.points = 3, level = 0.95, verbose = FALSE, check = TRUE )pk.tss.stepwise.linear( ..., min.points = 3, level = 0.95, verbose = FALSE, check = TRUE )
... |
|
min.points |
The minimum number of points required for the fit |
level |
The confidence level required for assessment of steady-state |
verbose |
Describe models as they are run, show convergence of the model (passed to the nlme function), and additional details while running. |
check |
The model is fit with a different magnitude by treatment (as a factor, if
given) and a random slope by subject (if given). A minimum of min.points
is required to fit the model.
A scalar float for the first time when steady-state is achieved or
NA if it is not observed.
Maganti L, Panebianco DL, Maes AL. Evaluation of Methods for Estimating Time to Steady State with Examples from Phase 1 Studies. AAPS Journal 10(1):141-7. doi:10.1208/s12248-008-9014-y
Other Time to steady-state calculations:
pk.tss(),
pk.tss.monoexponential()
Compute pharmacokinetic (PK) noncompartmental analysis (NCA) parameters.
PKNCA has been cross-validated with both Phoenix WinNonlin(R) and Pumas (click here for the cross-validation article)
A common workflow would load data from a file or database into a data.frame then run the following code.
Maintainer: Bill Denney [email protected] (ORCID)
Authors:
Bill Denney [email protected] (ORCID)
Clare Buckeridge [email protected]
Gerardo Jose Rodriguez [email protected] (ORCID)
Other contributors:
Sridhar Duvvuri [contributor]
Natalie Sang [email protected] [contributor]
Useful links:
Report bugs at https://github.com/humanpred/pknca/issues
## Not run: # Load concentration-time data into a data.frame called d.conc # with columns named "conc", "time", and "subject". my.conc <- PKNCAconc(d.conc, conc~time|subject) # Load dose-time data into a data.frame called d.dose # with columns named "dose", "time", and "subject". my.dose <- PKNCAdose(d.dose, dose~time|subject) # Combine the concentration-time and dose-time data into an object # ready for calculations. my.data <- PKNCAdata(my.conc, my.dose) # Perform the calculations my.results <- pk.nca(my.data) # Look at summary results summary(my.results) # Look at a listing of results as.data.frame(my.results) ## End(Not run)## Not run: # Load concentration-time data into a data.frame called d.conc # with columns named "conc", "time", and "subject". my.conc <- PKNCAconc(d.conc, conc~time|subject) # Load dose-time data into a data.frame called d.dose # with columns named "dose", "time", and "subject". my.dose <- PKNCAdose(d.dose, dose~time|subject) # Combine the concentration-time and dose-time data into an object # ready for calculations. my.data <- PKNCAdata(my.conc, my.dose) # Perform the calculations my.results <- pk.nca(my.data) # Look at summary results summary(my.results) # Look at a listing of results as.data.frame(my.results) ## End(Not run)
Enumerates the pptestcd_cdisc/pptest_cdisc values registered on every
NCA parameter (see add.interval.col() and get.interval.cols()),
expanding a route- or sparse-keyed mapping into one row per variant, and
flags whether each code is a real CDISC PKPARMCD term. Generated from the
registry at call time; never hand-written, so it always reflects the
parameters actually registered (including by another package).
pknca_cdisc_codes()pknca_cdisc_codes()
A parameter with no CDISC PKPARMCD equivalent (for example a
sample count or a standard error, neither of which CDISC assigns its own
PP parameter code) keeps a sponsor-defined code with in_ct FALSE;
that is expected for some "uncommon" tier parameters and, for a few
documented exceptions, for "common" tier ones as well (see the
comments at their add.interval.col() registrations).
A data.frame with one row per parameter/variant and columns
parameter, tier, variant ("single", a route, or "dense"/
"sparse"), pptestcd_cdisc, pptest_cdisc, and in_ct (whether
pptestcd_cdisc is a code in the CDISC PKPARMCD codelist, checked
against the installed cdiscdata package; NA for every row, with a
message, if cdiscdata is not installed).
pknca_parameter_table(), add.interval.col()
Other Interval specifications:
add.interval.col(),
check.interval.specification(),
choose.auc.intervals(),
get.interval.cols(),
get.parameter.deps(),
interval_add_impute(),
interval_add_param(),
interval_add_secondary(),
pknca_check_parameter_classification(),
pknca_concepts(),
pknca_interval_table(),
pknca_match_route(),
pknca_parameter_table(),
pknca_presets(),
pknca_ref()
head(pknca_cdisc_codes())head(pknca_cdisc_codes())
Intended for packages that register their own NCA parameters: call it in your tests to find parameters that will never be selected automatically because they carry no concept.
pknca_check_parameter_classification(param = NULL)pknca_check_parameter_classification(param = NULL)
param |
Parameter names to describe. The default is every registered parameter. |
A data.frame of the unclassifiable parameters, with the same
columns as pknca_parameter_table(). Zero rows means everything is
classified.
pknca_concept(), pknca_parameter_table()
Other Interval specifications:
add.interval.col(),
check.interval.specification(),
choose.auc.intervals(),
get.interval.cols(),
get.parameter.deps(),
interval_add_impute(),
interval_add_param(),
interval_add_secondary(),
pknca_cdisc_codes(),
pknca_concepts(),
pknca_interval_table(),
pknca_match_route(),
pknca_parameter_table(),
pknca_presets(),
pknca_ref()
pknca_check_parameter_classification()pknca_check_parameter_classification()
The concept is the kind of quantity a user asks for – "clearance" rather than the fifteen registered clearance parameters. It is stored as an attribute on the calculation function so that it sits with the code that computes it, and so that a parameter added by another package can carry one too.
pknca_concept(x) pknca_concept(x) <- valuepknca_concept(x) pknca_concept(x) <- value
x |
A parameter calculation function (for example |
value |
A concept name; see |
A function that computes different concepts depending on which
parameter it is registered for – pk.calc.dn() is the example within
PKNCA – should have no concept. Those parameters take the concept of the
parameter they depend on. When neither applies, set the concept for the
individual parameter with the selection argument of
add.interval.col().
pknca_concept() gives the concept, or NULL when none is set.
The replacement form gives the function with the attribute set.
pknca_concepts(), add.interval.col(), and the vignette
"Writing Parameter Functions"
pknca_concept(pk.calc.cmax)pknca_concept(pk.calc.cmax)
Concepts, tiers, and contexts used to classify NCA parameters
pknca_concepts() pknca_tiers() pknca_routes(synonyms = FALSE) pknca_dosing() pknca_sample_types()pknca_concepts() pknca_tiers() pknca_routes(synonyms = FALSE) pknca_dosing() pknca_sample_types()
synonyms |
If |
A tier of "common" marks a parameter that belongs in a default
report for at least one context; "uncommon" marks one that is calculated
only when asked for by name. "uncommon" is the default, so a parameter
registered without a tier is never selected automatically.
pknca_concepts() gives the concept names PKNCA uses,
pknca_tiers() the reporting tiers, pknca_routes() the routes of
administration, pknca_dosing() the dosing patterns, and
pknca_sample_types() the sample collection types.
pknca_routes(synonyms = TRUE) returns a data.frame with one row per
spelling and the columns
synonym: The spelling, in lower case with single spaces, as it may
appear in data (for example "po", "intravenous bolus"). It includes
the common abbreviations and the CDISC SDTM ROUTE controlled
terminology terms that are extravascular or intravascular routes.
route: One of pknca_routes(), or "iv" when the spelling is
intravascular but does not say which intravascular route it is (for
example "intravenous" does not say bolus or infusion). "iv" is not a
value of pknca_routes() without synonyms, because PKNCA cannot
calculate with a route that does not say how the drug entered.
dose_route: "extravascular" or "intravascular", the values that
PKNCAdose() accepts for route.
pknca_match_route() looks spellings up in this table.
pknca_concept(), add.interval.col()
Other Interval specifications:
add.interval.col(),
check.interval.specification(),
choose.auc.intervals(),
get.interval.cols(),
get.parameter.deps(),
interval_add_impute(),
interval_add_param(),
interval_add_secondary(),
pknca_cdisc_codes(),
pknca_check_parameter_classification(),
pknca_interval_table(),
pknca_match_route(),
pknca_parameter_table(),
pknca_presets(),
pknca_ref()
pknca_concepts()pknca_concepts()
pknca_difftime_to_unit() expresses a duration in the time unit of an
analysis, such as a collection duration that is the difference of two
date-times, so that it can be used with PKNCAconc() and PKNCAdose()
times and durations given in that unit. The same conversion turns
date-times and difftime durations into numbers in pk.nca().
pknca_difftime_to_unit(x, unit)pknca_difftime_to_unit(x, unit)
x |
A |
unit |
The time unit to express |
A difftime of any of its units (seconds, minutes, hours, days, or weeks)
is converted exactly, through seconds. unit may be any time unit that the
units package knows, such as "hr", "min", "day", or "week". Hours
("hr") need no conversion, so they work without the units package;
every other unit needs the units package installed, which stops with an
error from rlang if it is missing.
To convert a number that is not a difftime, say its unit first with
base::as.difftime().
A numeric vector the length of x: the duration in unit, with no
unit or other attributes
An x that is not a difftime stops with the class
pknca_error_difftime_not_difftime, because a plain number has no unit to
convert from. A unit that is not a single string, or that is not a time
unit the units package can convert hours to, stops with the class
pknca_error_difftime_unit.
# Hours need no conversion beyond the difftime's own unit pknca_difftime_to_unit(as.difftime(90, units = "mins"), unit = "hr") # Any other unit needs the units package pknca_difftime_to_unit(as.difftime(36, units = "hours"), unit = "day") # The difference of two date-times start <- as.POSIXct("2026-10-05 08:00:00", tz = "UTC") end <- as.POSIXct("2026-10-05 20:30:00", tz = "UTC") pknca_difftime_to_unit(difftime(end, start), unit = "min")# Hours need no conversion beyond the difftime's own unit pknca_difftime_to_unit(as.difftime(90, units = "mins"), unit = "hr") # Any other unit needs the units package pknca_difftime_to_unit(as.difftime(36, units = "hours"), unit = "day") # The difference of two date-times start <- as.POSIXct("2026-10-05 08:00:00", tz = "UTC") end <- as.POSIXct("2026-10-05 20:30:00", tz = "UTC") pknca_difftime_to_unit(difftime(end, start), unit = "min")
Every exclude_nca_*() rule is registered with its description and the
descriptions of its arguments. Its arguments and their defaults come from
the factory function, and the parameters it can exclude and the
PKNCA.options() entries it uses come from the exclusion function that the
factory returns when called with its defaults (an argument without a default
falls back to its option, as it does in use).
pknca_exclude_rules()pknca_exclude_rules()
A tibble with one row per rule and the columns:
The function name (for example, "exclude_nca_span.ratio")
The one-line description
A list column of data.frames with one row per argument and
the columns argument, default (the deparsed default, or NA when
there is none), and description
Can the rule be created without giving any arguments?
A list column of the PKNCA.options() names that the rule
uses when created with its defaults, or NULL when it cannot be
A list column of the NCA parameters that the
rule, created with its defaults, can exclude, or NULL when it cannot be
created without arguments
| Rule | Description | PKNCA.options() used |
exclude_nca_by_param() |
Exclude based on NCA parameter thresholds | (set by its arguments) |
exclude_nca_count_conc_measured() |
Exclude based on the count of concentrations measured and not below the lower limit of quantification (affects AUC and AUMC parameters) | (set by its arguments) |
exclude_nca_max.aucinf.pext() |
Exclude based on the percent of AUC extrapolated to infinity (both observed and predicted) | max.aucinf.pext |
exclude_nca_min.hl.adj.r.squared() |
Exclude based on half-life adjusted r-squared | (none) |
exclude_nca_min.hl.r.squared() |
Exclude based on half-life r-squared | min.hl.r.squared |
exclude_nca_span.ratio() |
Exclude based on the half-life span ratio | min.span.ratio |
exclude_nca_tmax_0() |
Exclude based on implausibly early Tmax (special case for tmax_early = 0) | (none) |
exclude_nca_tmax_coverage() |
Exclude based on whether a subject has a sample within Tukey's fences around the Tmax values of its group; the rule flags a subject with no sample within the inner fences, and excludes only a subject with no sample within the outer fences | (none) |
exclude_nca_tmax_early() |
Exclude based on implausibly early Tmax (often used for extravascular dosing with a Tmax value of 0) | (none) |
Other Result exclusions:
exclude(),
exclude_nca,
pknca_missing_samples()
rules <- pknca_exclude_rules() rules[, c("rule", "description")]rules <- pknca_exclude_rules() rules[, c("rule", "description")]
Find NCA parameters with a given unit type
pknca_find_units_param(unit_type)pknca_find_units_param(unit_type)
unit_type |
The type of unit as assigned with |
A character vector of parameters with a given unit type
Each imputation string is split at commas and spaces, and each method name
is expanded to its function name by adding PKNCA_impute_method_ to the
beginning. An error will be raised if the functions are not found.
PKNCA_impute_fun_list(x)PKNCA_impute_fun_list(x)
x |
The character vector of PKNCA imputation method strings (without
the |
A list with one element per element of x, each a character vector
of function names to run in order (or NA_character_ for no imputation).
assert_impute_method(), PKNCA_impute_method
Other Imputation:
PKNCA_impute_method,
assert_impute_method(),
get_impute_column(),
get_impute_method(),
pknca_impute_methods()
PKNCA_impute_fun_list(c("start_predose,start_conc0", NA))PKNCA_impute_fun_list(c("start_predose,start_conc0", NA))
Methods for imputation of data with PKNCA
PKNCA_impute_method_start_conc0(conc, time, start = 0, ..., options = list()) PKNCA_impute_method_start_cmin(conc, time, start, end, ..., options = list()) PKNCA_impute_method_start_predose( conc, time, start, end, conc.group, time.group, ..., max_shift = NA_real_, options = list() ) PKNCA_impute_method_start_predose_conc0( conc, time, start, end, conc.group, time.group, ..., max_shift = NA_real_, options = list() ) PKNCA_impute_method_end_conc_drop(conc, time, end, ..., options = list())PKNCA_impute_method_start_conc0(conc, time, start = 0, ..., options = list()) PKNCA_impute_method_start_cmin(conc, time, start, end, ..., options = list()) PKNCA_impute_method_start_predose( conc, time, start, end, conc.group, time.group, ..., max_shift = NA_real_, options = list() ) PKNCA_impute_method_start_predose_conc0( conc, time, start, end, conc.group, time.group, ..., max_shift = NA_real_, options = list() ) PKNCA_impute_method_end_conc_drop(conc, time, end, ..., options = list())
conc |
Measured concentrations |
time |
Time of the measurement of the concentrations |
start |
The start time of the interval |
... |
ignored |
options |
List of changes to the default PKNCA options (see
|
end |
The end time of the interval |
conc.group |
All concentrations measured for the group |
time.group |
Time of all concentrations measured for the group |
max_shift |
The maximum amount of time to shift a concentration forward
(defaults to 5% of the interval duration, i.e. |
A data.frame with one column named conc with imputed concentrations and one column named time with the times.
PKNCA_impute_method_start_conc0(): Set the concentration at the start time to 0, even if a nonzero concentration exists at that time (usually used with single-dose data). Forcing the start concentration to zero is intentional: an existing start-time value is replaced with 0, including a nonzero predose measurement shifted to the start time by start_predose, so the imputation chain "start_predose,start_conc0" gives the same result as "start_conc0" alone. To carry a predose measurement to the start time, use start_predose without start_conc0. When no observation exists at the start time, a new row with a concentration of 0 is added.
PKNCA_impute_method_start_cmin(): Add a new concentration of the minimum during the interval at the start time (usually used with multiple-dose data)
PKNCA_impute_method_start_predose(): Shift a predose concentration to become the time zero concentration (only if a time zero concentration does not exist). The most recent predose sample with a measured concentration is shifted; samples with a missing concentration are skipped.
PKNCA_impute_method_start_predose_conc0(): Use a predose concentration as the start concentration when one is available and 0 when it is not. A concentration measured at the start time is kept as-is, which is what distinguishes this from start_conc0: a measured concentration at the time of an intravenous bolus dose is the C0 for that dose, and start_conc0 would replace it with 0. The chain "start_predose,start_conc0" cannot express this, because start_conc0 overwrites whatever start_predose shifted.
PKNCA_impute_method_end_conc_drop(): Drop a concentration measured exactly at the end of the interval, if one is present (usually used with multiple-dose data when a point at the interval boundary belongs to the next dose, e.g. an imputed C0)
pknca_impute_methods() lists the methods.
Other Imputation:
PKNCA_impute_fun_list(),
assert_impute_method(),
get_impute_column(),
get_impute_method(),
pknca_impute_methods()
Every PKNCA_impute_method_*() function is registered with its
description; its arguments and their defaults come from the function
itself. The method names are what imputation strings use (see
PKNCA_impute_fun_list() and the impute argument of PKNCAdata()).
pknca_impute_methods()pknca_impute_methods()
Registration only describes PKNCA's own methods. A method is still found by
its function name: a user-defined PKNCA_impute_method_<name>() function
that PKNCA can see (for example, in the global environment) is used by the
imputation string "<name>" without being registered, and it is not listed
here.
A tibble with one row per method, sorted by method, and the columns:
The name used in imputation strings (for example,
"start_conc0")
The function name (for example,
"PKNCA_impute_method_start_conc0")
The one-line description
A list column of data.frames with one row per argument
and the columns argument and default (the deparsed default, or NA
when there is none)
| Method | Description |
"end_conc_drop" |
Drop a concentration measured exactly at the end of the interval, if one is present (usually used with multiple-dose data when a point at the interval boundary belongs to the next dose, e.g. an imputed C0) |
"start_cmin" |
Add a new concentration of the minimum during the interval at the start time (usually used with multiple-dose data) |
"start_conc0" |
Set the concentration at the start time to 0, even if a nonzero concentration exists at that time (usually used with single-dose data). |
"start_predose" |
Shift a predose concentration to become the time zero concentration (only if a time zero concentration does not exist). |
"start_predose_conc0" |
Use a predose concentration as the start concentration when one is available and 0 when it is not. |
Other Imputation:
PKNCA_impute_fun_list(),
PKNCA_impute_method,
assert_impute_method(),
get_impute_column(),
get_impute_method()
pknca_impute_methods()[, c("method", "description")]pknca_impute_methods()[, c("method", "description")]
Chooses the NCA parameters to calculate for an interval, and the imputation
to calculate them from, given when the interval runs and how the drug was
given. The result is a data.frame suitable for the intervals argument of
PKNCAdata().
pknca_interval_table( start, end, dosing = "single", route = "extravascular", sample_type = "spot", sparse = FALSE, tier = "common", include = NULL, exclude = NULL, impute = NULL, preset = NULL, clast_type = "obs", ... )pknca_interval_table( start, end, dosing = "single", route = "extravascular", sample_type = "spot", sparse = FALSE, tier = "common", include = NULL, exclude = NULL, impute = NULL, preset = NULL, clast_type = "obs", ... )
start, end
|
The start and end time of the interval. Both may be vectors, giving one set of rows per interval. |
dosing |
Was the drug given once ( |
route |
How the drug was given; see |
sample_type |
Were concentrations measured in samples taken at a point
in time ( |
sparse |
Is this a sparse sampling design? The parameters chosen are
the same either way – the AUCs and AUMCs with a sparse estimator are
estimated with the sparse methods when the data are sparse, and the rest
are calculated from the arithmetic-mean profile – but the imputation
differs: the sparse estimators accept only an imputed zero, so a sparse
single dose imputes zero at the start ( |
tier |
|
include, exclude
|
NCA parameters or concepts (see |
impute |
The imputation to use, as for |
preset |
A named set of arguments to start from; see
|
clast_type |
Should the extrapolation to infinity use the observed
( |
... |
Columns to add to every row, typically the groups the interval applies to. |
The interval is assumed to start at a dose, which is what makes an
imputation at the start meaningful. Pass impute = NA for an interval
that starts partway through a profile.
Which AUC the interval is built on follows from dosing: a single dose
uses AUClast and the extrapolation to infinity, and a repeated dose uses
the AUCint family, which interpolates at both interval boundaries. The
clearance, volume, and mean residence time that follow from that AUC are
chosen to match.
A data.frame with one or more rows per interval: start, end, a
logical column per parameter, an impute column when any imputation
applies, and any columns given in .... An interval is split into more
than one row when some of its parameters must not be calculated from the
imputed data.
pknca_parameter_table() for how each parameter is classified,
PKNCAdata(), and the vignette "Selection of Calculation Intervals"
Other Interval specifications:
add.interval.col(),
check.interval.specification(),
choose.auc.intervals(),
get.interval.cols(),
get.parameter.deps(),
interval_add_impute(),
interval_add_param(),
interval_add_secondary(),
pknca_cdisc_codes(),
pknca_check_parameter_classification(),
pknca_concepts(),
pknca_match_route(),
pknca_parameter_table(),
pknca_presets(),
pknca_ref()
# A single oral dose pknca_interval_table(0, 24, dosing = "single", route = "extravascular") # At steady state, with the fluctuation parameters added pknca_interval_table( 144, 168, dosing = "steady_state", route = "extravascular", include = "fluctuation" ) # A urine collection pknca_interval_table(0, 24, dosing = "single", route = "extravascular", sample_type = "interval")# A single oral dose pknca_interval_table(0, 24, dosing = "single", route = "extravascular") # At steady state, with the fluctuation parameters added pknca_interval_table( 144, 168, dosing = "steady_state", route = "extravascular", include = "fluctuation" ) # A urine collection pknca_interval_table(0, 24, dosing = "single", route = "extravascular", sample_type = "interval")
Match spellings of a route of administration to the route PKNCA uses
pknca_match_route(x)pknca_match_route(x)
x |
A character vector (or factor) of route spellings, such as |
A data.frame with one row for each element of x and the columns
route (one of pknca_routes(), or "iv" when the spelling is
intravascular but does not say which intravascular route it is) and dose_route ("extravascular" or
"intravascular", the values PKNCAdose() accepts for route). Both
are NA when the spelling is not known or x is NA.
The Route synonyms section of pknca_routes() for the spellings
that are known.
Other Interval specifications:
add.interval.col(),
check.interval.specification(),
choose.auc.intervals(),
get.interval.cols(),
get.parameter.deps(),
interval_add_impute(),
interval_add_param(),
interval_add_secondary(),
pknca_cdisc_codes(),
pknca_check_parameter_classification(),
pknca_concepts(),
pknca_interval_table(),
pknca_parameter_table(),
pknca_presets(),
pknca_ref()
pknca_match_route(c("PO", "Intravenous", "IV BOLUS", "unknown"))pknca_match_route(c("PO", "Intravenous", "IV BOLUS", "unknown"))
The schedule of a group is every nominal time that has a row in the
concentration data of that group, where the group is every grouping variable
of the concentration data except the subject (for example, the study,
treatment, and analyte). Each subject of the group is expected to have a
usable concentration at every time of its group's schedule, and a time
without one is reported. Missing samples are therefore found only when
some subject of the group has a row at that nominal time; a time that no
subject has a row for is not part of the schedule. Recording a missed
sample as a row with an NA concentration keeps the time in the schedule
even when every subject missed it.
pknca_missing_samples(object)pknca_missing_samples(object)
object |
A PKNCAconc, PKNCAdata, or PKNCAresults object (the
concentration data of a PKNCAdata or PKNCAresults object are checked).
Its concentration data must have a nominal time (the |
A nominal time of a subject's schedule is reported with one of these reasons:
"no row": the subject has no row at that nominal time.
"NA concentration": every row of the subject at that nominal time has an
NA concentration.
"excluded": the subject has a concentration at that nominal time, but
every row with one is excluded (with the exclude column of
PKNCAconc() or with exclude()), so the calculations do not use it.
A concentration below the limit of quantification (zero) is a usable
sample. Rows with an NA nominal time (unscheduled samples) are not part
of any schedule, and they neither add a time to it nor fill one. Nominal
times are compared as they are, so they may be in any unit.
The nominal times must share one origin for each subject (for example, the
time since the first dose). Nominal times that restart at each dose repeat
for each dose, so one dose's samples would fill another dose's missing
times. They are found when a subject's nominal times go back to the
start of its schedule (its first nominal time after zero, or earlier) while
its actual times increase; two samples drawn out of order are not a
restart. The groups with such a subject are not reported, and a
pknca_warning_missing_samples_nominal_restart warning names them.
Sparse data (see the sparse argument of PKNCAconc()) have no schedule
that each subject follows: each subject gives a few of the group's
samples by design. For sparse data, only the rows that exist are checked
(reasons "NA concentration" and "excluded"), and a message says that
absent rows are not reported.
A data.frame with one row per missing sample and the columns: the
grouping columns of the concentration data other than the subject, the
subject column, the nominal time column (with the names they have in the
concentration data), and reason. It is sorted by those columns and has
no rows when no sample is missing.
exclude_nca_tmax_coverage(), which excludes the results of a
subject whose samples miss the Tmax range of its group
Other Result exclusions:
exclude(),
exclude_nca,
pknca_exclude_rules()
d_conc <- data.frame( subject = rep(1:3, each = 4), time_nominal = rep(c(0, 1, 2, 4), 3), time = rep(c(0, 1, 2, 4), 3), conc = c(0, 5, 3, 1, 0, 4, NA, 1, 0, 6, 2, 1) ) # Subject 3 has no sample at 4 hours d_conc <- d_conc[-12, ] o_conc <- PKNCAconc(d_conc, conc ~ time | subject, time.nominal = "time_nominal") pknca_missing_samples(o_conc)d_conc <- data.frame( subject = rep(1:3, each = 4), time_nominal = rep(c(0, 1, 2, 4), 3), time = rep(c(0, 1, 2, 4), 3), conc = c(0, 5, 3, 1, 0, 4, NA, 1, 0, 6, 2, 1) ) # Subject 3 has no sample at 4 hours d_conc <- d_conc[-12, ] o_conc <- PKNCAconc(d_conc, conc ~ time | subject, time.nominal = "time_nominal") pknca_missing_samples(o_conc)
Unlike PKNCA.options(default = TRUE), which resets the current options to
their defaults, this only reads the default values.
PKNCA_options_defaults(name = NULL)PKNCA_options_defaults(name = NULL)
name |
The option name(s) requested, or |
For one name, the default value of that option; otherwise, a
named list of default values (all options when name is NULL).
PKNCA.options(), PKNCA.options.describe()
Other PKNCA calculation and summary settings:
PKNCA.choose.option(),
PKNCA.options(),
PKNCA.set.summary()
PKNCA_options_defaults("min.span.ratio") # The current options are not changed PKNCA.options(min.span.ratio = 3) PKNCA_options_defaults("min.span.ratio") PKNCA.options("min.span.ratio") PKNCA.options(default = TRUE)PKNCA_options_defaults("min.span.ratio") # The current options are not changed PKNCA.options(min.span.ratio = 3) PKNCA_options_defaults("min.span.ratio") PKNCA.options("min.span.ratio") PKNCA.options(default = TRUE)
How each NCA parameter is classified for interval selection
pknca_parameter_table(param = NULL)pknca_parameter_table(param = NULL)
param |
Parameter names to describe. The default is every registered parameter. |
A parameter whose concept could not be resolved has NA for
concept. That is not an error: it is calculated normally when asked
for by name, but it is never selected automatically.
A data.frame with one row per parameter and columns for the
concept, tier, sample_type, whether it is sparse,
dose_normalized, or secondary (needing inputs from more than one
profile), and the route and dosing contexts it applies to
(comma-separated).
pknca_concept(), get.interval.cols()
Other Interval specifications:
add.interval.col(),
check.interval.specification(),
choose.auc.intervals(),
get.interval.cols(),
get.parameter.deps(),
interval_add_impute(),
interval_add_param(),
interval_add_secondary(),
pknca_cdisc_codes(),
pknca_check_parameter_classification(),
pknca_concepts(),
pknca_interval_table(),
pknca_match_route(),
pknca_presets(),
pknca_ref()
head(pknca_parameter_table())head(pknca_parameter_table())
Named argument sets for building an interval specification
pknca_presets()pknca_presets()
A named list of the arguments each preset gives to
pknca_interval_table(). Arguments given to that function directly
override the preset.
Other Interval specifications:
add.interval.col(),
check.interval.specification(),
choose.auc.intervals(),
get.interval.cols(),
get.parameter.deps(),
interval_add_impute(),
interval_add_param(),
interval_add_secondary(),
pknca_cdisc_codes(),
pknca_check_parameter_classification(),
pknca_concepts(),
pknca_interval_table(),
pknca_match_route(),
pknca_parameter_table(),
pknca_ref()
names(pknca_presets()) pknca_presets()$bioequivalencenames(pknca_presets()) pknca_presets()$bioequivalence
Used in the formalsmap argument of add.interval.col() to declare that an
argument takes the value of param calculated in the reference interval
(the interval named by the <parameter>_ref column of the interval
specification) rather than in the current interval.
pknca_ref(param) is_pknca_ref(x)pknca_ref(param) is_pknca_ref(x)
param |
The name of the NCA parameter to take from the reference
interval (a single non-missing character string). It does not need to be
registered yet when |
x |
An object to test. |
An object of class pknca_ref.
add.interval.col(), the vignette "Secondary parameters"
Other Interval specifications:
add.interval.col(),
check.interval.specification(),
choose.auc.intervals(),
get.interval.cols(),
get.parameter.deps(),
interval_add_impute(),
interval_add_param(),
interval_add_secondary(),
pknca_cdisc_codes(),
pknca_check_parameter_classification(),
pknca_concepts(),
pknca_interval_table(),
pknca_match_route(),
pknca_parameter_table(),
pknca_presets()
pknca_ref("aucinf.obs")pknca_ref("aucinf.obs")
Perform unit conversion (if possible) on PKNCA results
pknca_unit_conversion(result, units, allow_partial_missing_units = FALSE)pknca_unit_conversion(result, units, allow_partial_missing_units = FALSE)
result |
The results data.frame |
units |
The unit conversion table |
allow_partial_missing_units |
Should missing units be allowed for some but not all parameters? |
The result table with units converted
The conversions of pknca_units_table() are requested by the user and so
fail loudly when they cannot be made. This answers the different question of
whether two units PKNCA derived itself can be reconciled – units that are
unrelated (a concentration and an amount) or outside udunits ("IU/mL") are
an expected answer of "no" rather than a mistake.
pknca_unit_reconcile_factor(from, to)pknca_unit_reconcile_factor(from, to)
from, to
|
Single unit strings, as they appear in the "PPORRESU" and "PPSTRESU" columns of a unit conversion table |
The number that a value in from units is multiplied by to express
it in to units, or NA_real_ when the two are not convertible or the
units package is not installed.
Add parentheses to a unit value, if needed
pknca_units_add_paren(unit)pknca_units_add_paren(unit)
unit |
The text of the unit |
The unit with parentheses around it, if needed
Find the factor converting a value from one unit to another
pknca_units_conversion_factor(from, to)pknca_units_conversion_factor(from, to)
from, to
|
Single unit strings, as they appear in the "PPORRESU" and "PPSTRESU" columns of a unit conversion table |
The number that a value in from units is multiplied by to express
it in to units. Units that the units package cannot convert between
are an error.
This data.frame is typically used for the units argument for PKNCAdata().
If a unit is not given, then all of the units derived from that unit will be
NA.
pknca_units_table(concu, ...) ## Default S3 method: pknca_units_table( concu, doseu, amountu, timeu, concu_pref = NULL, doseu_pref = NULL, amountu_pref = NULL, timeu_pref = NULL, conversions = data.frame(), ... ) ## S3 method for class 'PKNCAdata' pknca_units_table(concu, ..., conversions = data.frame())pknca_units_table(concu, ...) ## Default S3 method: pknca_units_table( concu, doseu, amountu, timeu, concu_pref = NULL, doseu_pref = NULL, amountu_pref = NULL, timeu_pref = NULL, conversions = data.frame(), ... ) ## S3 method for class 'PKNCAdata' pknca_units_table(concu, ..., conversions = data.frame())
concu, doseu, amountu, timeu
|
Units for concentration, dose, amount, and time in the source data |
... |
Additional arguments (not used) |
concu_pref, doseu_pref, amountu_pref, timeu_pref
|
Preferred units for
reporting; |
conversions |
An optional data.frame with columns of c("PPORRESU",
"PPSTRESU", "conversion_factor") for the original calculation units, the
standardized units, and a conversion factor to multiply the initial value
by to get a standardized value. This argument overrides any preferred unit
conversions from |
A unit conversion table with columns for "PPTESTCD" and "PPORRESU"
if conversions is not given, and adding "PPSTRESU" and
"conversion_factor" if conversions is given.
A secondary parameter (renal clearance, bioavailability, a ratio; see
vignette("v09-secondary-parameters")) takes one value from the interval
requesting it and another from a reference interval, so its units are a
quotient of the two groups' units. When the PKNCAdata method finds more
than one set of units among the groups, the table therefore gains a
<group column>_ref column for each of its group columns and, for each
secondary parameter, one row per pair of (own group, reference group) with
"PPORRESU" composed from the correct side of each. Rows describing a
result that names no reference – every primary parameter, and a secondary
parameter calculated without a reference – hold NA in the _ref
columns, and results carrying no reference group join to them. A quotient
whose two sides are convertible into one another is dimensionless, and such
a row also gets "PPSTRESU" of "fraction" with the "conversion_factor" that
turns the raw quotient into that number.
With one set of units for every group there is no reference side to name
and no _ref column is added.
The units argument for PKNCAdata()
pknca_units_table() # only parameters that are unitless pknca_units_table( concu="ng/mL", doseu="mg/kg", amountu="mg", timeu="hr" ) # Automatic unit conversion needs the units package pknca_units_table( concu="ng/mL", doseu="mg/kg", amountu="mg", timeu="hr", # Convert clearance and volume units to more understandable units with # automatic unit conversion conversions=data.frame( PPORRESU=c("(mg/kg)/(hr*ng/mL)", "(mg/kg)/(ng/mL)"), PPSTRESU=c("mL/hr/kg", "mL/kg") ) ) pknca_units_table( concu="mg/L", doseu="mg/kg", amountu="mg", timeu="hr", # Convert clearance and volume units to molar units (assuming conversions=data.frame( PPORRESU=c("mg/L", "(mg/kg)/(hr*ng/mL)", "(mg/kg)/(ng/mL)"), PPSTRESU=c("mmol/L", "mL/hr/kg", "mL/kg"), # Manual conversion of concentration units from ng/mL to mmol/L (assuming # a molecular weight of 138.121 g/mol) conversion_factor=c(1/138.121, NA, NA) ) ) # This will make all time-related parameters use "day" even though the # original units are "hr" pknca_units_table( concu = "ng/mL", doseu = "mg/kg", timeu = "hr", amountu = "mg", timeu_pref = "day" )pknca_units_table() # only parameters that are unitless pknca_units_table( concu="ng/mL", doseu="mg/kg", amountu="mg", timeu="hr" ) # Automatic unit conversion needs the units package pknca_units_table( concu="ng/mL", doseu="mg/kg", amountu="mg", timeu="hr", # Convert clearance and volume units to more understandable units with # automatic unit conversion conversions=data.frame( PPORRESU=c("(mg/kg)/(hr*ng/mL)", "(mg/kg)/(ng/mL)"), PPSTRESU=c("mL/hr/kg", "mL/kg") ) ) pknca_units_table( concu="mg/L", doseu="mg/kg", amountu="mg", timeu="hr", # Convert clearance and volume units to molar units (assuming conversions=data.frame( PPORRESU=c("mg/L", "(mg/kg)/(hr*ng/mL)", "(mg/kg)/(ng/mL)"), PPSTRESU=c("mmol/L", "mL/hr/kg", "mL/kg"), # Manual conversion of concentration units from ng/mL to mmol/L (assuming # a molecular weight of 138.121 g/mol) conversion_factor=c(1/138.121, NA, NA) ) ) # This will make all time-related parameters use "day" even though the # original units are "hr" pknca_units_table( concu = "ng/mL", doseu = "mg/kg", timeu = "hr", amountu = "mg", timeu_pref = "day" )
Choose either the value from an option list or the current set value for an option.
PKNCA.choose.option(name, value = NULL, options = list())PKNCA.choose.option(name, value = NULL, options = list())
name |
The option name requested. |
value |
A value to check for the option ( |
options |
List of changes to the default PKNCA options (see
|
The value of the option first from the options list and if it is
not there then from the current settings.
Other PKNCA calculation and summary settings:
PKNCA.options(),
PKNCA.set.summary(),
PKNCA_options_defaults()
This function will set the default PKNCA options. If given no inputs, it
will provide the current option set. If given name/value pairs, it will set
the option (as in the options() function). If given a name, it will return
the value for the parameter. If given the default option as true, it will
provide the default options.
PKNCA.options(..., default = FALSE, check = FALSE, name, value)PKNCA.options(..., default = FALSE, check = FALSE, name, value)
... |
options to set or get the value for |
default |
(re)sets all default options |
check |
check a single option given, but do not set it (for validation of the values when used in another function) |
name |
An option name to use with the |
value |
An option value (paired with the |
Options are either for calculation or summary functions. Calculation options
are required for a calculation function to report a result (otherwise the
reported value will be NA). Summary options are used during summarization
and are used for assessing what values are included in the summary.
See the vignette 'Options for Controlling PKNCA' for a current list of
options (vignette("Options-for-Controlling-PKNCA", package="PKNCA")).
If...
returns the current options.
returns NULL
the current value of that option is returned as a scalar
the current values of those options are returned as a list
Other PKNCA calculation and summary settings:
PKNCA.choose.option(),
PKNCA.set.summary(),
PKNCA_options_defaults()
PKNCA.options() PKNCA.options(default=TRUE) PKNCA.options("auc.method") PKNCA.options(name="auc.method") PKNCA.options(auc.method="lin up/log down", min.hl.points=3)PKNCA.options() PKNCA.options(default=TRUE) PKNCA.options("auc.method") PKNCA.options(name="auc.method") PKNCA.options(auc.method="lin up/log down", min.hl.points=3)
Describe a PKNCA.options option by name.
PKNCA.options.describe(name)PKNCA.options.describe(name)
name |
The option name requested. |
A character string of the description.
Define how NCA parameters are summarized.
PKNCA.set.summary( name, description, point, spread, rounding = list(signif = 3), reset = FALSE, spread_for = NULL )PKNCA.set.summary( name, description, point, spread, rounding = list(signif = 3), reset = FALSE, spread_for = NULL )
name |
The parameter name or a vector of parameter names. It must have
already been defined (see |
description |
A single-line description of the summary |
point |
The function to calculate the point estimate for the summary.
The function will be called as |
spread |
Optional. The function to calculate the spread (or
variability). The function will be called as |
rounding |
Instructions for how to round the value of point and spread. It may either be a list or a function. If it is a list, then it must have a single entry with a name of either "signif" or "round" and a value of the digits to round. If a function, it is expected to return a scalar number or character string with the correct results for an input of either a scalar or a two-long vector. |
reset |
Reset all the summary instructions to no instruction (this is not intended for general use) |
spread_for |
Optional. The name of another parameter that |
All current summary settings (invisibly)
Other PKNCA calculation and summary settings:
PKNCA.choose.option(),
PKNCA.options(),
PKNCA_options_defaults()
## Not run: PKNCA.set.summary( name="half.life", description="arithmetic mean and standard deviation", point=business.mean, spread=business.sd, rounding=list(signif=3) ) ## End(Not run)## Not run: PKNCA.set.summary( name="half.life", description="arithmetic mean and standard deviation", point=business.mean, spread=business.sd, rounding=list(signif=3) ) ## End(Not run)
Create a PKNCAconc object
PKNCAconc(data, ...) ## Default S3 method: PKNCAconc(data, ...) ## S3 method for class 'tbl_df' PKNCAconc(data, ...) ## S3 method for class 'data.frame' PKNCAconc( data, formula, subject, time.nominal, exclude = NULL, duration, volume, exclude_half.life, include_half.life, lloq, sparse = FALSE, ..., concu = NULL, amountu = NULL, timeu = NULL, concu_pref = NULL, amountu_pref = NULL, timeu_pref = NULL )PKNCAconc(data, ...) ## Default S3 method: PKNCAconc(data, ...) ## S3 method for class 'tbl_df' PKNCAconc(data, ...) ## S3 method for class 'data.frame' PKNCAconc( data, formula, subject, time.nominal, exclude = NULL, duration, volume, exclude_half.life, include_half.life, lloq, sparse = FALSE, ..., concu = NULL, amountu = NULL, timeu = NULL, concu_pref = NULL, amountu_pref = NULL, timeu_pref = NULL )
data |
A data frame with concentration (or amount for urine/feces),
time, and the groups defined in |
... |
Ignored. |
formula |
The formula defining the |
subject |
The column indicating the subject number. If not provided,
this defaults to the last grouping variable to the left of a |
time.nominal |
(optional) The name of the nominal time column (if the
main time variable is actual time. The |
exclude |
(optional) The name of a column with concentrations to exclude
from calculations and summarization. If given, the column should have
values of |
duration |
(optional) The duration of collection as is typically used
for concentration measurements in urine or feces. The |
volume |
(optional) The volume (or mass) of collection as is typically
used for urine or feces measurements. A |
exclude_half.life, include_half.life
|
Manual half-life point selection,
given as a logical value per concentration measurement (or, in
|
lloq |
(optional) The lower limit of quantification used by the Tobit
half-life method ( |
sparse |
Are the concentration-time data sparse PK (commonly used in small nonclinical species or with terminal or difficult sampling) or dense PK (commonly used in clinical studies or larger nonclinical species)? |
concu, amountu, timeu
|
Either unit values (e.g. "ng/mL") or column names
within the data where units are provided. For a date-time (POSIXct or
Date) time column, |
concu_pref, amountu_pref, timeu_pref
|
Preferred units for reporting (not
column names). For a date-time time column, the times are converted
directly to |
A PKNCAconc object that can be used for automated NCA.
The concentration time (and the dose time in PKNCAdose()) may be a
date-time (POSIXct) or a date (Date; a date is taken as 08:00 on that
date, a typical time of a first PK sample, with a warning). Date-times have no numeric unit, so
they are converted directly to the time unit used for calculations and
reports: timeu_pref when given (it takes precedence over timeu, and
timeu is set to it), otherwise timeu, otherwise hours (without
units). The unit must be a single time unit value (like "hr" or
"day"), not a column name. A numeric duration (here or in
PKNCAdose()) is in that unit, and a difftime duration is converted to
it exactly.
The times remain date-times in the PKNCAconc, PKNCAdose, and
PKNCAdata objects. pk.nca() converts them to numeric time relative to
the first dose (or first concentration) in each group; see the "Date-time
input" section of PKNCAdata(). The nominal time (time.nominal) is not converted and usually
stays numeric.
Other PKNCA objects:
PKNCAdata(),
PKNCAdose(),
PKNCAresults()
PKNCAdata() combines PKNCAconc and PKNCAdose objects and adds in the
intervals for PK calculations.
PKNCAdata(data.conc, data.dose, ...) ## S3 method for class 'PKNCAconc' PKNCAdata(data.conc, data.dose, ...) ## S3 method for class 'PKNCAdose' PKNCAdata(data.conc, data.dose, ...) ## Default S3 method: PKNCAdata( data.conc, data.dose, ..., formula.conc, formula.dose, impute = NA_character_, intervals, units, options = list(), group_ref = NULL, grpid_cols = NULL, grpid_numeric = NULL )PKNCAdata(data.conc, data.dose, ...) ## S3 method for class 'PKNCAconc' PKNCAdata(data.conc, data.dose, ...) ## S3 method for class 'PKNCAdose' PKNCAdata(data.conc, data.dose, ...) ## Default S3 method: PKNCAdata( data.conc, data.dose, ..., formula.conc, formula.dose, impute = NA_character_, intervals, units, options = list(), group_ref = NULL, grpid_cols = NULL, grpid_numeric = NULL )
data.conc |
Concentration data as a |
data.dose |
Dosing data as a |
... |
arguments passed to |
formula.conc |
Formula for making a |
formula.dose |
Formula for making a |
impute |
Methods for imputation. |
intervals |
A data frame with the AUC interval specifications as defined
in |
units |
A data.frame of unit assignments and conversions as created by
|
options |
List of changes to the default PKNCA options (see
|
group_ref |
The reference profiles for automatically-linked secondary
parameters, as a data.frame of group values, optionally
parameter-specific (see Details). |
grpid_cols |
The grouping columns that prefix the interval number in
the PPGRPID column of |
grpid_numeric |
The names of the columns in |
If data.dose is not given or is NA, then the intervals must be
given. At least one of data.dose and intervals must be given.
A secondary parameter is calculated from a result in another interval, and
the interval specification links the two with an interval_id column and a
<parameter>_ref pointer (see interval_add_secondary()). An
interval_id identifies one interval: rows that share it (an interval
split by imputation, for example) may differ only in the parameters they
request, never in start, end, or the groups. Where a request
has no pointer and could not otherwise be calculated, pk.nca() derives the
reference profile from the data: a parameter measured on an interval
collection whose inputs are spot samples (renal clearance) takes the nearest
profile with no collection volume, and group_ref restricts – or, for
anything else, supplies – the profiles that may be used. The derived
reference interval is created for the calculation only and is not added to
the intervals in the result. When more than one profile is equally close,
the affected results are NA with the reason in the exclude column and a
pknca_warning_secondary_auto_reference warning.
group_ref takes three forms. A data.frame of group values applies to
every secondary parameter: its columns must be group columns of the
concentration data, every column must match (and) for at least one of its
rows (or), and every value must appear in the data – for example, with
groups crossing TRTP, PCTEST, and PCSPEC,
group_ref = data.frame(PCSPEC = "PLASMA") directs renal-clearance
references to the plasma profiles and
group_ref = data.frame(PCTEST = "midazolam") directs metabolite ratios
to the parent analyte. The same data.frame with a parameter column
applies each row only to the secondary parameter it names, and the columns
a parameter's rows leave NA do not apply to it, so one table can steer
renal clearance by PCSPEC and a metabolite ratio by PCTEST:
group_ref = data.frame(parameter = c("clr.obs", "ratio.aucinf.obs"), PCSPEC = c("PLASMA", NA), PCTEST = c(NA, "midazolam")). A named list of
data.frames, one per parameter, says the same thing:
group_ref = list(clr.obs = data.frame(PCSPEC = "PLASMA"), ratio.aucinf.obs = data.frame(PCTEST = "midazolam")).
A PKNCAdata object with concentration, dose, interval, and calculation options stored (note that PKNCAdata objects can also have results after a NCA calculations are done to the data).
The concentration and dose times may be date-times (POSIXct) or dates
(Date). PKNCAdata() checks them and keeps them as they are, and
pk.nca() converts them to numeric time before it calculates, so the
intervals can still be changed after PKNCAdata():
The time reference is the first dose (ignoring excluded doses) within
each combination of the grouping variables (and the subject) shared by
the concentration and dose formulas. With dose~time|Part+Subject,
each subject's first dose in each study part (or period, for a
crossover) is time 0; with dose~time|Subject, each subject's first
dose of the study is time 0. The dose formula must include the subject,
so that one reference is never shared by several subjects.
A subject (group) without an included dose time uses its first
concentration (the first one not excluded) as the reference, with a
warning. Without dosing data, every reference is the first
concentration, within each combination of the concentration grouping
variables to the left of any / (so analytes share their subject's
reference).
Sparse data use one reference per group rather than per subject, because every subject in a sparse group shares the group's dosing.
Numeric time is in the time unit of the PKNCAconc() object:
timeu_pref when given, otherwise timeu, otherwise hours (without
units). Numeric concentration collection and dosing durations are in
that unit, and difftime durations are converted to it.
Manually specified intervals may be numeric times relative to the
time reference, in that unit, or date-times. Date-time start and
end (POSIXct, or Date for 08:00, with a warning) are converted
relative to the reference of the group each row applies to. A row that
does not name every reference group (for example, a row without
Subject) applies to every matching group and becomes one row per
group, because one absolute window is a different relative window for
each subject. A date-time start may pair with end = Inf (or a
POSIXct Inf), which stays infinite; the start must be finite, both
bounds must otherwise be date-times, and the time zone must match the
data. PKNCAdata() and set_intervals() check date-time intervals,
and pk.nca() converts them; converted intervals have an
interval_time_kind column ("datetime", or "relative" for numeric
rows added later). The conversion gives the window only: a window
starting before a subject's first measurement still needs an
imputation rule (impute) for a concentration at its start.
The results of pk.nca() keep the converted data that the calculation
used (results$data), with the time reference of each group in its
time_reference element and the time_reference_type column saying
whether it is the "first_dose" or the "first_conc";
as.data.frame(results, out_format = "cdisc") gives, in the PPRFTDTC
column, the date-time of the reference of each row: the dose that
starts its interval, or the first concentration for a "first_conc"
group (see as.data.frame.PKNCAresults()).
Both times must be date-times (or dates), not one numeric and one
date-time; date-times must have the same time zone; and the dose formula
must include the subject of dense data. Otherwise, it is an error.
Differences are elapsed time, so a change to or from daylight saving time
is handled correctly when the time zone is a named zone (like
"America/New_York").
choose.auc.intervals(), pk.nca(), pknca_units_table()
Other PKNCA objects:
PKNCAconc(),
PKNCAdose(),
PKNCAresults()
Create a PKNCAdose object
PKNCAdose(data, ...) ## Default S3 method: PKNCAdose(data, ...) ## S3 method for class 'tbl_df' PKNCAdose(data, ...) ## S3 method for class 'data.frame' PKNCAdose( data, formula, route, rate, duration, time.nominal, exclude = NULL, ..., doseu = NULL, doseu_pref = NULL )PKNCAdose(data, ...) ## Default S3 method: PKNCAdose(data, ...) ## S3 method for class 'tbl_df' PKNCAdose(data, ...) ## S3 method for class 'data.frame' PKNCAdose( data, formula, route, rate, duration, time.nominal, exclude = NULL, ..., doseu = NULL, doseu_pref = NULL )
data |
A data frame with time and the groups defined in |
... |
Ignored. |
formula |
The formula defining the |
route |
Define the route of administration. The value may be either a
column name from the |
rate, duration
|
(optional) for |
time.nominal |
(optional) The name of the nominal time column (if the
main time variable is actual time. The |
exclude |
(optional) The name of a column with doses to exclude
from calculations and summarization. If given, the column should have
values of |
doseu |
Either unit values (e.g. "mg") or column names within the data where units are provided. |
doseu_pref |
Preferred units for reporting (not column names) |
The formula for a PKNCAdose object can be
given three ways: one-sided (missing left side), one-sided (missing
right side), or two-sided. Each of the three ways can be given
with or without groups. When given one-sided missing the left
side, the left side can either be omitted or can be given as a
period (.): ~time|treatment+subject and
.~time|treatment+subject are identical, and dose-related NCA
parameters will all be reported as not calculable (for example,
clearance). When given one-sided missing the right side, the right
side must be specified as a period (.):
dose~.|treatment+subject, and only a single row may be given
per group. When the right side is missing, PKNCA assumes that the
same dose is given in every interval. When given as a two-sided
formula, both the dose amount and time are used directly from the
data.
A PKNCAdose object that can be used for automated NCA.
Other PKNCA objects:
PKNCAconc(),
PKNCAdata(),
PKNCAresults()
This function should not be run directly. The object is created for summarization.
PKNCAresults(result, data, exclude = NULL)PKNCAresults(result, data, exclude = NULL)
result |
a data frame with NCA calculation results and groups. Each row is one interval and each column is a group name or the name of an NCA parameter. |
data |
The PKNCAdata used to generate the result |
exclude |
(optional) The name of a column with concentrations to exclude
from calculations and summarization. If given, the column should have
values of |
A PKNCAresults object with each of the above within.
Other PKNCA objects:
PKNCAconc(),
PKNCAdata(),
PKNCAdose()
Print and/or summarize a PKNCAconc or PKNCAdose object.
## S3 method for class 'PKNCAconc' print(x, n = 6, summarize = FALSE, ...) ## S3 method for class 'PKNCAconc' summary(object, n = 0, summarize = TRUE, ...) ## S3 method for class 'PKNCAdose' print(x, n = 6, summarize = FALSE, ...) ## S3 method for class 'PKNCAdose' summary(object, n = 0, summarize = TRUE, ...)## S3 method for class 'PKNCAconc' print(x, n = 6, summarize = FALSE, ...) ## S3 method for class 'PKNCAconc' summary(object, n = 0, summarize = TRUE, ...) ## S3 method for class 'PKNCAdose' print(x, n = 6, summarize = FALSE, ...) ## S3 method for class 'PKNCAdose' summary(object, n = 0, summarize = TRUE, ...)
x |
The object to print |
n |
The number of rows of data to show (see
|
summarize |
Summarize the nested number of groups |
... |
Arguments passed to |
object |
The object to summarize |
Print a PKNCAdata object
## S3 method for class 'PKNCAdata' print(x, ...)## S3 method for class 'PKNCAdata' print(x, ...)
x |
The object to print |
... |
Arguments passed on to |
Print the summary of a provenance object
## S3 method for class 'provenance' print(x, ...)## S3 method for class 'provenance' print(x, ...)
x |
The object to be printed |
... |
Ignored |
invisible text of the printed information
Print the results summary
## S3 method for class 'summary_PKNCAresults' print(x, ...)## S3 method for class 'summary_PKNCAresults' print(x, ...)
x |
A summary_PKNCAresults object |
... |
passed to print.data.frame ( |
x invisibly
A tau column in the interval specification takes precedence over
detection so that designs where only the steady-state dose is present in the
dosing data (nothing repeats, so nothing can be detected) can still be
calculated. Otherwise tau is detected from the group's dose times with
find.tau(), which gives a "pknca_warning_tau_irregular_dosing" warning
when the doses are spaced as though one was missed.
resolve_dose_tau(interval, time.dose, options = list(), timeu = NULL)resolve_dose_tau(interval, time.dose, options = list(), timeu = NULL)
interval |
One row of an interval definition (see
|
time.dose |
The dose times for the whole group (not just the interval;
an interval one |
options |
List of changes to the default PKNCA options (see
|
timeu |
The time unit of |
The dosing interval, or NA_real_ when it cannot be determined
Other Interval determination:
choose.auc.intervals(),
find.dose.regimen(),
find.tau()
During the summarization of PKNCAresults, do the rounding of values based on the instructions given.
roundingSummarize(x, name)roundingSummarize(x, name)
x |
The values to summarize |
name |
The NCA parameter name (matching a parameter name in
|
A string of the rounded value
Round a value to a defined number of digits printing out trailing zeros, if applicable.
roundString(x, digits = 0, sci_range = Inf, sci_sep = "e", si_range)roundString(x, digits = 0, sci_range = Inf, sci_sep = "e", si_range)
x |
The number to round |
digits |
integer indicating the number of decimal places |
sci_range |
See help for |
sci_sep |
The separator to use for scientific notation strings (typically this will be either "e" or "x10^" for computer- or human-readable output). |
si_range |
Deprecated, please use |
Values that are not standard numbers like Inf, NA, and
NaN are returned as "Inf", "NA", and NaN.
A string with the value
This function identifies the smallest set of columns in a data frame whose unique combinations can reconstruct the grouping structure defined by the specified strata columns. It removes duplicate, constant, and redundant columns, then searches for the minimal combination that uniquely identifies each stratum.
select_minimal_grouping_cols(df, strata_cols)select_minimal_grouping_cols(df, strata_cols)
df |
A data frame. |
strata_cols |
Column names in df whose unique combination defines the strata. |
A data frame containing the strata columns and their minimal set of grouping columns.
Takes in two objects, the PKNCAdata object and the proposed intervals. It will then check that the intervals are valid, given the data object. If the intervals are valid, it will set them in the object. It will return the data object with the intervals set.
set_intervals(data, intervals)set_intervals(data, intervals)
data |
PKNCAdata object |
intervals |
Proposed intervals |
With date-time data, start and end may be date-times; they are kept
as given and converted to numeric time relative to each group's time
reference by pk.nca() (see the "Date-time input" section of
PKNCAdata()).
The data object with the intervals set.
Add an attribute to an object where the attribute is added as a name to the names of the object.
setAttributeColumn( object, attr_name, col_or_value, col_name, default_value, stop_if_default, warn_if_default, message_if_default )setAttributeColumn( object, attr_name, col_or_value, col_name, default_value, stop_if_default, warn_if_default, message_if_default )
object |
The object to set the attribute column on. |
attr_name |
The attribute name to set |
col_or_value |
If this exists as a column in the data, it is used as the
|
col_name |
The name of the column within the dataset to use (if missing,
uses |
default_value |
The value to fill in the column if the column does not
exist (the column is filled with |
stop_if_default, warn_if_default, message_if_default
|
A character string
to provide as an error, a warning, or a message to the user if the
|
The object with the attribute column added to the data.
Set the duration of dosing or measurement
## S3 method for class 'PKNCAconc' setDuration(object, duration, ...) setDuration(object, ...) ## S3 method for class 'PKNCAdose' setDuration(object, duration, rate, dose, ...)## S3 method for class 'PKNCAconc' setDuration(object, duration, ...) setDuration(object, ...) ## S3 method for class 'PKNCAdose' setDuration(object, duration, rate, dose, ...)
object |
An object to set a duration on |
duration |
The value to set for the duration or the name of the column in the data to use for the duration. |
... |
Arguments passed to another setDuration function |
rate |
(for PKNCAdose objects only) The rate of infusion |
dose |
(for PKNCAdose objects only) The dose amount |
The object with duration set
This function adds the exclude column to an object. To change the
exclude value, use the exclude() function.
setExcludeColumn(object, exclude = NULL, dataname = "data")setExcludeColumn(object, exclude = NULL, dataname = "data")
object |
The object to set the exclude column on. |
exclude |
The column name to set as the exclude value. |
dataname |
The name of the data.frame within the object to add the exclude column to. |
The object with an exclude column and attribute
Set the dosing route
setRoute(object, ...) ## S3 method for class 'PKNCAdose' setRoute(object, route, ...)setRoute(object, ...) ## S3 method for class 'PKNCAdose' setRoute(object, route, ...)
object |
A PKNCAdose object |
... |
Arguments passed to another setRoute function |
route |
A character string indicating one of the following: the column from the data which indicates the route of administration, a scalar indicating the route of administration for all subjects, or a vector indicating the route of administration for each dose in the dataset. |
The object with an updated route
Round a value to a defined number of significant digits printing out trailing zeros, if applicable.
signifString(x, ...) ## S3 method for class 'data.frame' signifString(x, ...) ## Default S3 method: signifString(x, digits = 6, sci_range = 6, sci_sep = "e", si_range, ...)signifString(x, ...) ## S3 method for class 'data.frame' signifString(x, ...) ## Default S3 method: signifString(x, digits = 6, sci_range = 6, sci_sep = "e", si_range, ...)
x |
The number to round |
... |
Arguments passed to methods. |
digits |
integer indicating the number of significant digits |
sci_range |
integer (or |
sci_sep |
The separator to use for scientific notation strings (typically this will be either "e" or "x10^" for computer- or human-readable output). |
si_range |
Deprecated, please use |
Values that are not standard numbers like Inf, NA, and
NaN are returned as "Inf", "NA", and NaN.
A string with the value
The weight is used as the parameter in pk.calc.sparse_auc()
sparse_auc_weight_linear(sparse_pk)sparse_auc_weight_linear(sparse_pk)
sparse_pk |
A sparse_pk object from |
Where:
is the weight at time i
and
are the changes between time i-1 and i or i and i+1 (zero outside of the time range)
is the time at time i
A numeric vector of weights for sparse AUC calculations the same
length as sparse_pk
Other Sparse Methods:
as_sparse_pk(),
pk.calc.aucinf.obs_sparse(),
pk.calc.aucivlast_sparse(),
pk.calc.auclast_sparse(),
pk.calc.sparse_auc(),
pk.calc.sparse_aumc(),
sparse_bootstrap(),
sparse_mean(),
summary.PKNCAresults_sparse_bootstrap()
sparse_bootstrap() makes a new sparse PKNCAconc() object holding the
original data and n_boot bootstrap replicates of it, following the
stratified nonparametric bootstrap of Shen and Machado (2017). Each
replicate resamples the animals with replacement within each stratum, where
the stratum is the set of times an animal was sampled: each sampling time
with serial sacrifice, or each batch in a batch design. An animal's samples
stay together, so the correlation between samples from the same animal is
kept. pk.nca() then calculates every parameter for every replicate the
same way as for the original data (from the arithmetic-mean profile, or with
the sparse estimators). Its results summarize the replicates with
summary(), and be_assess()
compares groups with the percentile intervals of the replicates.
sparse_bootstrap( object, n_boot = 200, seed = NULL, paired = NULL, replicate_col = "bootstrap" )sparse_bootstrap( object, n_boot = 200, seed = NULL, paired = NULL, replicate_col = "bootstrap" )
object |
A sparse |
n_boot |
The number of bootstrap replicates. The default of 200 is enough for the mean and standard deviation of the parameters (Takemoto et al. 2006); percentile confidence intervals need more replicates to be stable. |
seed |
The random seed for the resampling. When |
paired |
Group columns whose levels each animal has, so they are resampled together (for example, the treatment of a crossover design) |
replicate_col |
The name of the replicate group column to add |
The replicates are a new group (replicate_col) with the values
"original" (the data as given) and "bootstrap1" through
"bootstrap<n_boot>". A resampled animal gets a new subject identifier
(<replicate_col>_subject, the original subject with the draw number) so
that an animal drawn twice counts as two animals.
Groups named in paired, and the analytes (the groups after / in the
formula), are resampled together: an animal drawn for a replicate brings
its samples from every level of those groups. Use paired for a crossover,
where each animal (or eye, as in Shen and Machado 2017) receives each
treatment. Other groups (such as the treatment of a parallel design) are
resampled independently.
The "original" replicate holds the data as given, so the same pk.nca()
run also gives the estimates.
A sparse PKNCAconc object with the original data and the
replicates. Its bootstrap element records n_boot, seed, paired,
replicate_col, and the original subject column.
Shen M, Machado SG. Bioequivalence evaluation of sparse sampling pharmacokinetics data using bootstrap resampling method. Journal of Biopharmaceutical Statistics. 2017;27(2):257-264. doi:10.1080/10543406.2016.1265543
Takemoto S, Yamaoka K, Nishikawa M, Takakura Y. Histogram analysis of pharmacokinetic parameters by bootstrap resampling from one-point sampling data in animal experiments. Drug Metabolism and Pharmacokinetics. 2006;21(6):458-464. doi:10.2133/dmpk.21.458
Other Sparse Methods:
as_sparse_pk(),
pk.calc.aucinf.obs_sparse(),
pk.calc.aucivlast_sparse(),
pk.calc.auclast_sparse(),
pk.calc.sparse_auc(),
pk.calc.sparse_aumc(),
sparse_auc_weight_linear(),
sparse_mean(),
summary.PKNCAresults_sparse_bootstrap()
d_sparse <- data.frame( time = rep(c(0, 1, 2, 4, 8, 24), each = 3), conc = c(0, 0, 0, 5, 6, 4, 8, 7, 9, 6, 5, 7, 3, 2.5, 3.5, 0.6, 0.4, 0.5) ) d_sparse$animal <- seq_len(nrow(d_sparse)) o_conc <- PKNCAconc(d_sparse, conc ~ time | animal, sparse = TRUE) o_conc_boot <- sparse_bootstrap(o_conc, n_boot = 20, seed = 1) o_data_boot <- PKNCAdata(o_conc_boot, intervals = data.frame(start = 0, end = 24, auclast = TRUE, cmax = TRUE)) summary(pk.nca(o_data_boot))d_sparse <- data.frame( time = rep(c(0, 1, 2, 4, 8, 24), each = 3), conc = c(0, 0, 0, 5, 6, 4, 8, 7, 9, 6, 5, 7, 3, 2.5, 3.5, 0.6, 0.4, 0.5) ) d_sparse$animal <- seq_len(nrow(d_sparse)) o_conc <- PKNCAconc(d_sparse, conc ~ time | animal, sparse = TRUE) o_conc_boot <- sparse_bootstrap(o_conc, n_boot = 20, seed = 1) o_data_boot <- PKNCAdata(o_conc_boot, intervals = data.frame(start = 0, end = 24, auclast = TRUE, cmax = TRUE)) summary(pk.nca(o_data_boot))
Choices for the method of calculation (the argument sparse_mean_method)
are:
sparse_mean( sparse_pk, sparse_mean_method = c("arithmetic mean, <=50% BLQ", "arithmetic mean") )sparse_mean( sparse_pk, sparse_mean_method = c("arithmetic mean, <=50% BLQ", "arithmetic mean") )
sparse_pk |
A sparse_pk object from |
sparse_mean_method |
The method used to calculate the sparse mean (see details) |
Arithmetic mean (ignoring number of BLQ samples)
If >50% of the measurements are BLQ, zero. Otherwise, the arithmetic mean of all samples (including the BLQ as zero).
A vector the same length as sparse_pk with the mean concentration
at each of those times.
Other Sparse Methods:
as_sparse_pk(),
pk.calc.aucinf.obs_sparse(),
pk.calc.aucivlast_sparse(),
pk.calc.auclast_sparse(),
pk.calc.sparse_auc(),
pk.calc.sparse_aumc(),
sparse_auc_weight_linear(),
sparse_bootstrap(),
summary.PKNCAresults_sparse_bootstrap()
Set or get a sparse_pk object attribute
sparse_pk_attribute(sparse_pk, ...)sparse_pk_attribute(sparse_pk, ...)
sparse_pk |
A sparse_pk object from |
... |
Either a character string (to get that value) or a named vector
the same length as |
Either the attribute value or an updated sparse_pk object
Extract the mean concentration-time profile as a data.frame
sparse_to_dense_pk(sparse_pk)sparse_to_dense_pk(sparse_pk)
sparse_pk |
A sparse_pk object from |
A data.frame with names of "conc" and "time"
Summarize a PKNCAdata object showing important details about the concentration, dosing, and interval information.
## S3 method for class 'PKNCAdata' summary(object, ...)## S3 method for class 'PKNCAdata' summary(object, ...)
object |
The PKNCAdata object to summarize. |
... |
arguments passed on to |
Summarize PKNCA results
## S3 method for class 'PKNCAresults' summary( object, ..., drop_group = as_PKNCAconc(object)$columns$subject, drop_param = character(), summarize_n = NA, not_requested = ".", not_calculated = "NC", drop.group = deprecated(), summarize.n.per.group = deprecated(), not.requested.string = deprecated(), not.calculated.string = deprecated(), pretty_names = NULL, caption_prefix = NULL )## S3 method for class 'PKNCAresults' summary( object, ..., drop_group = as_PKNCAconc(object)$columns$subject, drop_param = character(), summarize_n = NA, not_requested = ".", not_calculated = "NC", drop.group = deprecated(), summarize.n.per.group = deprecated(), not.requested.string = deprecated(), not.calculated.string = deprecated(), pretty_names = NULL, caption_prefix = NULL )
object |
The results to summarize |
... |
Ignored. |
drop_group |
Which group(s) should be dropped from the formula? |
drop_param |
Which parameters should be excluded from the summary? |
summarize_n |
Should a column for |
not_requested |
A character string to use when a parameter summary was not requested for a parameter within an interval. |
not_calculated |
A character string to use when a parameter summary was
requested, but the point estimate AND spread calculations (if applicable)
returned |
drop.group, summarize.n.per.group, not.requested.string, not.calculated.string
|
Deprecated use |
pretty_names |
Should pretty names (easier to understand in a report) be
used? |
caption_prefix |
Prefix to prepend to the generated table caption. |
Excluded results will not be included in the summary.
A parameter whose summary instructions name it as the spread of another
parameter (spread_for in PKNCA.set.summary(), such as the standard error
of a sparse AUClast) has no column of its own. Where its results are
present, the other parameter is summarized with its instructions instead:
for a sparse AUClast, the estimate with its standard error. The caption
gives the summary used. A summary row with more than one sparse estimate is
an error, since each standard error describes one estimate.
A data frame of NCA parameter results summarized according to the summarization settings.
PKNCA.set.summary(), print.summary_PKNCAresults()
conc_obj <- PKNCAconc(as.data.frame(datasets::Theoph), conc ~ Time | Subject) d_dose <- unique(datasets::Theoph[ datasets::Theoph$Time == 0, c("Dose", "Time", "Subject") ]) dose_obj <- PKNCAdose(d_dose, Dose ~ Time | Subject) data_obj_automatic <- PKNCAdata(conc_obj, dose_obj) results_obj_automatic <- pk.nca(data_obj_automatic) # To get standard results run summary summary(results_obj_automatic) # To enable numeric conversion and extraction, do not give a spread function # and subsequently run as.numeric on the result columns. PKNCA.set.summary( name = c("auclast", "cmax", "half.life", "aucinf.obs"), point = business.geomean, description = "geometric mean" ) PKNCA.set.summary( name = c("tmax"), point = business.median, description = "median" ) summary(results_obj_automatic, not_requested = "NA")conc_obj <- PKNCAconc(as.data.frame(datasets::Theoph), conc ~ Time | Subject) d_dose <- unique(datasets::Theoph[ datasets::Theoph$Time == 0, c("Dose", "Time", "Subject") ]) dose_obj <- PKNCAdose(d_dose, Dose ~ Time | Subject) data_obj_automatic <- PKNCAdata(conc_obj, dose_obj) results_obj_automatic <- pk.nca(data_obj_automatic) # To get standard results run summary summary(results_obj_automatic) # To enable numeric conversion and extraction, do not give a spread function # and subsequently run as.numeric on the result columns. PKNCA.set.summary( name = c("auclast", "cmax", "half.life", "aucinf.obs"), point = business.geomean, description = "geometric mean" ) PKNCA.set.summary( name = c("tmax"), point = business.median, description = "median" ) summary(results_obj_automatic, not_requested = "NA")
The bootstrap replicates (see sparse_bootstrap()) are summarized the way
subjects are for dense data (see summary.PKNCAresults()), with each
parameter's summary statistics from PKNCA.set.summary(): for example, the
geometric mean and geometric coefficient of variation of the replicates'
AUClast. N is the number of animals in the study, and the caption gives
the number of bootstrap replicates and the random seed. The original data
and the sparse standard errors of single replicates are not part of the
summary. For confidence intervals and comparisons between groups, see
be_assess().
## S3 method for class 'PKNCAresults_sparse_bootstrap' summary(object, ..., drop_group = character(), summarize_n = NA)## S3 method for class 'PKNCAresults_sparse_bootstrap' summary(object, ..., drop_group = character(), summarize_n = NA)
object |
The results to summarize |
... |
Ignored. |
drop_group |
Groups to drop from the summary, in addition to the bootstrap replicate |
summarize_n |
Should a column for |
A data frame of the summarized bootstrap results (see
summary.PKNCAresults())
Other Sparse Methods:
as_sparse_pk(),
pk.calc.aucinf.obs_sparse(),
pk.calc.aucivlast_sparse(),
pk.calc.auclast_sparse(),
pk.calc.sparse_auc(),
pk.calc.sparse_aumc(),
sparse_auc_weight_linear(),
sparse_bootstrap(),
sparse_mean()
Compute noncompartmental superposition for repeated dosing
superposition(conc, ...) ## S3 method for class 'PKNCAconc' superposition(conc, ...) ## S3 method for class 'numeric' superposition( conc, time, dose.input = NULL, tau, dose.times = 0, dose.amount, n.tau = Inf, options = list(), lambda.z, clast.pred = FALSE, tlast, additional.times = numeric(), check.blq = TRUE, method = NULL, auc.type = "AUCinf", steady.state.tol = 0.001, ... )superposition(conc, ...) ## S3 method for class 'PKNCAconc' superposition(conc, ...) ## S3 method for class 'numeric' superposition( conc, time, dose.input = NULL, tau, dose.times = 0, dose.amount, n.tau = Inf, options = list(), lambda.z, clast.pred = FALSE, tlast, additional.times = numeric(), check.blq = TRUE, method = NULL, auc.type = "AUCinf", steady.state.tol = 0.001, ... )
conc |
Measured concentrations |
... |
Additional arguments passed to the |
time |
Time of the measurement of the concentrations |
dose.input |
The dose given to generate the |
tau |
The dosing interval |
dose.times |
The time of dosing within the dosing interval. The
|
dose.amount |
The doses given for the output. Linear proportionality
will be used from the input to output if they are not equal. The length of
dose.amount must be either 1 or matching the length of |
n.tau |
The number of tau dosing intervals to simulate or |
options |
List of changes to the default PKNCA options (see
|
lambda.z |
The elimination rate (in units of inverse time) for extrapolation |
clast.pred |
To use predicted as opposed to observed Clast, either give the value for clast.pred here or set it to true (for automatic calculation from the half-life). |
tlast |
The time of last observed concentration above the limit of quantification. This is calculated if not provided. |
additional.times |
Times to include in the final outputs in addition to
the standard times (see details). All |
check.blq |
Must the first concentration measurement be below the limit of quantification? |
method |
The method for integration (one of 'lin up/log down', 'lin-log', or 'linear') |
auc.type |
The type of AUC to compute. Choices are 'AUCinf', 'AUClast', and 'AUCall'. |
steady.state.tol |
The tolerance for assessing if steady-state has been achieved (between 0 and 1, exclusive). |
The returned superposition times will include all of the following
times: 0 (zero), dose.times, time modulo tau (shifting time for each
dose time as well), additional.times, and tau.
When concentrations are extrapolated as zero after tlast (for example,
auc.type = "AUClast" when tlast < tau), some concentrations in the
profile can never become nonzero. Steady-state (n.tau = Inf) is then
assessed on the nonzero concentrations, and a warning is given that zero
concentrations remain in the steady-state profile.
A data frame with columns named "conc" and "time".
Times relative to an event (typically dosing)
time_calc(time_event, time_obs, units = NULL)time_calc(time_event, time_obs, units = NULL)
time_event |
A vector of times for events |
time_obs |
A vector of times for observations |
units |
Passed to |
A data.frame with columns for:
The index of time_event that is the last one before time_obs or NA if none are before.
The index of time_event that is the first one after time_obs or NA if none are after.
The minimum time that the current time_obs is before a time_event, 0 if at least one time_obs == time_event.
The minimum time that the current time_obs is after a time_event, 0 if at least one time_obs == time_event.
The time after the first event (may be negative or positive).
time_after and time_before are calculated if they are at the same time as
a dose, they equal zero, and otherwise, they are calculated relative to the
dose number in the event_number_* columns.
A helper function to generate the formula and starting values for the parameters in monoexponential models.
tss.monoexponential.generate.formula(data)tss.monoexponential.generate.formula(data)
data |
The data used for the model |
a list with elements for each of the variables
The only thing that can change in the update is the concentration or dose
data. All other items (column definitions, etc) must remain the same. If
options are not set in data, then the default PKNCA options will be
considered identical.
## S3 method for class 'PKNCAresults' update(object, data, ...)## S3 method for class 'PKNCAresults' update(object, data, ...)
object |
The PKNCAresults data |
data |
The new PKNCAdata object |
... |
Ignored |
If more than the allowed settings change, then a full recalculation will occur.
This function is typically used with Shiny apps which may repeat analyses with small changes (e.g. point exclusion).
The PKNCAresults with updated new data
Equation 7.vii in Nedelman and Jia, 1998 is used for this calculation:
var_sparse_auc(sparse_pk)var_sparse_auc(sparse_pk)
sparse_pk |
A sparse_pk object from |
The degrees of freedom are the Satterthwaite approximation of equation 6 of
the same paper for any sampling design, including subjects with more than
one sample (see the "df" attribute of the return value and Details of
cov_holder() for the covariance).
When the animals form groups sampled at exactly the same times, with no time sampled in more than one group (serial sacrifice, batch, and complete designs), the same variance and degrees of freedom are calculated from the weighted sum of each animal's samples, which is much faster for many animals. For serial sacrifice, the degrees of freedom are then equation 6a of Nedelman, Gibiansky, and Lau (1995).
The variance of the AUC estimate with a "df" attribute containing
its degrees of freedom.
Nedelman JR, Jia X. An extension of Satterthwaite’s approximation applied to pharmacokinetics. Journal of Biopharmaceutical Statistics. 1998;8(2):317-328. doi:10.1080/10543409808835241
Holder DJ. Comments on Nedelman and Jia’s Extension of Satterthwaite’s Approximation Applied to Pharmacokinetics. Journal of Biopharmaceutical Statistics. 2001;11(1-2):75-79. doi:10.1081/BIP-100104199
Nedelman JR, Gibiansky E, Lau DTW. Applying Bailer's method for AUC confidence intervals to sparse sampling. Pharmaceutical Research. 1995;12(1):124-128.