| Type: | Package |
| Title: | Perform Pharmacokinetic Non-Compartmental Analysis |
| Version: | 0.12.1 |
| Imports: | checkmate, dplyr (≥ 0.5.0), digest, nlme, purrr, rlang,stats, tidyr, tibble, utils, lifecycle |
| Suggests: | covr, cowplot, ggplot2, knitr, labeling, pander, pmxTools,rmarkdown, spelling, testthat (≥ 3.0.0), units, withr |
| Description: | Compute standard Non-Compartmental Analysis (NCA) parameters for typical pharmacokinetic analyses and summarize them. |
| License: | AGPL-3 |
| URL: | https://humanpred.github.io/pknca/,https://github.com/humanpred/pknca,http://humanpred.github.io/pknca/ |
| BugReports: | https://github.com/humanpred/pknca/issues |
| NeedsCompilation: | no |
| VignetteBuilder: | knitr |
| RoxygenNote: | 7.3.2 |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| Language: | en-US |
| Packaged: | 2025-08-19 00:38:28 UTC; bill |
| Author: | Bill Denney |
| Maintainer: | Bill Denney <wdenney@humanpredictions.com> |
| Repository: | CRAN |
| Date/Publication: | 2025-08-19 04:40:02 UTC |
Compute noncompartmental pharmacokinetics
Description
Compute pharmacokinetic (PK) noncompartmental analysis (NCA)parameters.
Details
PKNCA has been cross-validated with both Phoenix WinNonlin(R) and Pumas(click here for thecross-validation article)
A common workflow would load data from a file or database into adata.frame then run the following code.
Author(s)
Maintainer: Bill Denneywdenney@humanpredictions.com (ORCID)
Authors:
Clare Buckeridgeclare.buckeridge@pfizer.com
Gerardo Jose Rodriguezgerardo.jrac@gmail.com (ORCID)
Other contributors:
Sridhar Duvvuri [contributor]
See Also
Useful links:
Report bugs athttps://github.com/humanpred/pknca/issues
Examples
## 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 calculationsmy.results <- pk.nca(my.data)# Look at summary resultssummary(my.results)# Look at a listing of resultsas.data.frame(my.results)## End(Not run)Choose either the value from an option list or the current set value for anoption.
Description
Choose either the value from an option list or the current set value for anoption.
Usage
PKNCA.choose.option(name, value = NULL, options = list())Arguments
name | The option name requested. |
value | A value to check for the option ( |
options | List of changes to the default PKNCA options (see |
Value
The value of the option first from theoptions list and if it isnot there then from the current settings.
See Also
Other PKNCA calculation and summary settings:PKNCA.options(),PKNCA.set.summary()
Set default options for PKNCA functions
Description
This function will set the default PKNCA options. If given no inputs, itwill provide the current option set. If given name/value pairs, it will setthe option (as in theoptions() function). If given a name, it will returnthe value for the parameter. If given thedefault option as true, it willprovide the default options.
Usage
PKNCA.options(..., default = FALSE, check = FALSE, name, value)Arguments
... | 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 validationof the values when used in another function) |
name | An option name to use with the |
value | An option value (paired with the |
Details
Options are either for calculation or summary functions. Calculation optionsare required for a calculation function to report a result (otherwise thereported value will beNA). Summary options are used during summarizationand are used for assessing what values are included in the summary.
See the vignette 'Options for Controlling PKNCA' for a current list ofoptions (vignette("Options-for-Controlling-PKNCA", package="PKNCA")).
Value
If...
- no arguments are given
returns the current options.
- a value is set (including the defaults)
returns
NULL- a single value is requested
the current value of that option is returned as a scalar
- multiple values are requested
the current values of those options are returned as a list
See Also
Other PKNCA calculation and summary settings:PKNCA.choose.option(),PKNCA.set.summary()
Examples
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.
Description
Describe a PKNCA.options option by name.
Usage
PKNCA.options.describe(name)Arguments
name | The option name requested. |
Value
A character string of the description.
See Also
Define how NCA parameters are summarized.
Description
Define how NCA parameters are summarized.
Usage
PKNCA.set.summary( name, description, point, spread, rounding = list(signif = 3), reset = FALSE)Arguments
name | The parameter name or a vector of parameter names. It must havealready 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 (orvariability). 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 havea single entry with a name of either "signif" or "round" and a value of thedigits to round. If a function, it is expected to return a scalar numberor character string with the correct results for an input of either ascalar or a two-long vector. |
reset | Reset all the summary instructions |
Value
All current summary settings (invisibly)
See Also
Other PKNCA calculation and summary settings:PKNCA.choose.option(),PKNCA.options()
Examples
## 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)Separate out a vector of PKNCA imputation methods into a list of functions
Description
An error will be raised if the functions are not found.
Usage
PKNCA_impute_fun_list(x)Arguments
x | The character vector of PKNCA imputation method functions (withoutthe |
Details
This function is not for use by users of PKNCA.
Value
A list of character vectors of functions to run.
Methods for imputation of data with PKNCA
Description
Methods for imputation of data with PKNCA
Usage
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())Arguments
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. |
Value
A data.frame with one column named conc with imputed concentrationsand one column named time with the times.
Functions
PKNCA_impute_method_start_conc0(): Add a new concentration of 0 at the starttime, even if a nonzero concentration exists at that time (usually usedwith single-dose data)PKNCA_impute_method_start_cmin(): Add a new concentration of the minimum duringthe interval at the start time (usually used with multiple-dose data)PKNCA_impute_method_start_predose(): Shift a predose concentration to become thetime zero concentration (only if a time zero concentration does not exist)
Create a PKNCAconc object
Description
Create a PKNCAconc object
Usage
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, sparse = FALSE, ..., concu = NULL, amountu = NULL, timeu = NULL, concu_pref = NULL, amountu_pref = NULL, timeu_pref = NULL)Arguments
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 beginning of the inner groups: For example with |
time.nominal | (optional) The name of the nominal time column (if themain time variable is actual time. The |
exclude | (optional) The name of a column with concentrations to excludefrom calculations and summarization. If given, the column should havevalues of |
duration | (optional) The duration of collection as is typically usedfor concentration measurements in urine or feces. |
volume | (optional) The volume (or mass) of collection as is typicallyused for urine or feces measurements. |
exclude_half.life,include_half.life | A character scalar for the columnname in the dataset of the points to exclude from the half-life calculation(still using normal curve-stripping selection rules for the other points)or to include for the half-life (using specifically those points andbypassing automatic curve-stripping point selection). See the "Half-LifeCalculation" vignette for more details on the use of these arguments. |
sparse | Are the concentration-time data sparse PK (commonly used insmall nonclinical species or with terminal or difficult sampling) or densePK (commonly used in clinical studies or larger nonclinical species)? |
concu,amountu,timeu | Either unit values (e.g. "ng/mL") or column nameswithin the data where units are provided. |
concu_pref,amountu_pref,timeu_pref | Preferred units for reporting (notcolumn names) |
Value
A PKNCAconc object that can be used for automated NCA.
See Also
Other PKNCA objects:PKNCAdata(),PKNCAdose(),PKNCAresults()
Create a PKNCAdata object.
Description
PKNCAdata() combinesPKNCAconc andPKNCAdose objects and adds in theintervals for PK calculations.
Usage
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())Arguments
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 definedin |
units | A data.frame of unit assignments and conversions as created by |
options | List of changes to the default PKNCA options (see |
Details
Ifdata.dose is not given or isNA, then theintervals must begiven. At least one ofdata.dose andintervals must be given.
Value
A PKNCAdata object with concentration, dose, interval, andcalculation options stored (note that PKNCAdata objects can also haveresults after a NCA calculations are done to the data).
See Also
choose.auc.intervals(),pk.nca(),pknca_units_table()
Other PKNCA objects:PKNCAconc(),PKNCAdose(),PKNCAresults()
Create a PKNCAdose object
Description
Create a PKNCAdose object
Usage
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)Arguments
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 acolumn name from the |
rate,duration | (optional) for |
time.nominal | (optional) The name of the nominal time column (if themain time variable is actual time. The |
exclude | (optional) The name of a column with concentrations to excludefrom calculations and summarization. If given, the column should havevalues of |
doseu | Either unit values (e.g. "mg") or column names within the datawhere units are provided. |
doseu_pref | Preferred units for reporting (not column names) |
Details
Theformula for aPKNCAdose object can begiven three ways: one-sided (missing left side), one-sided (missingright side), or two-sided. Each of the three ways can be givenwith or without groups. When given one-sided missing the leftside, the left side can either be omitted or can be given as aperiod (.):~time|treatment+subject and.~time|treatment+subject are identical, and dose-related NCAparameters will all be reported as not calculable (for example,clearance). When given one-sided missing the right side, the rightside must be specified as a period (.):dose~.|treatment+subject, and only a single row may be givenper group. When the right side is missing, PKNCA assumes that thesame dose is given in every interval. When given as a two-sidedformula
Value
A PKNCAconc object that can be used for automated NCA.
See Also
Other PKNCA objects:PKNCAconc(),PKNCAdata(),PKNCAresults()
Generate a PKNCAresults object
Description
This function should not be run directly. The object is created forsummarization.
Usage
PKNCAresults(result, data, exclude = NULL)Arguments
result | a data frame with NCA calculation results and groups. Each rowis one interval and each column is a group name or the name of an NCAparameter. |
data | The PKNCAdata used to generate the result |
exclude | (optional) The name of a column with concentrations to excludefrom calculations and summarization. If given, the column should havevalues of |
Value
A PKNCAresults object with each of the above within.
See Also
Other PKNCA objects:PKNCAconc(),PKNCAdata(),PKNCAdose()
Add columns for calculations within PKNCA intervals
Description
Add columns for calculations within PKNCA intervals
Usage
add.interval.col( name, FUN, values = c(FALSE, TRUE), unit_type, pretty_name, depends = NULL, desc = "", sparse = FALSE, formalsmap = list(), datatype = c("interval", "individual", "population"))Arguments
name | The column name as a character string |
FUN | The function to run (as a character string) or |
values | Valid values for the column |
unit_type | The type of units to use for assigning and converting units. |
pretty_name | The name of the parameter to use for printing in summarytables with units. (If an analysis does not include units, then the normalname is used.) |
depends | Character vector of columns that must be run before thiscolumn. |
desc | A human-readable description of the parameter (<=40 characters tocomply with SDTM) |
sparse | Is the calculation for sparse PK? |
formalsmap | A named list mapping parameter names in the function callto NCA parameter names. See the details for information on use of |
datatype | The type of data used for the calculation |
Details
Theformalsmap argument enables mapping some alternate formalargument names to parameters. It is used to generalize functions that mayuse multiple similar arguments (such as the variants of mean residence time).The names of the list should correspond to function formal parameter namesand the values should be one of the following:
For the current interval:
- character strings of NCA parameter name
The value of the parameter calculated for the current interval.
- "conc"
Concentration measurements for the current interval.
- "time"
Times associated with concentration measurements for the current interval (values start at 0 at the beginning of the current interval).
- "volume"
Volume associated with concentration measurements for the current interval (typically applies for excretion parameters like urine).
- "duration.conc"
Durations associated with concentration measurements for the current interval.
- "dose"
Dose amounts assocuated with the current interval.
- "time.dose"
Time of dose start associated with the current interval (values start at 0 at the beginning of the current interval).
- "duration.dose"
Duration of dose (typically infusion duration) for doses in the current interval.
- "route"
Route of dosing for the current interval.
- "start"
Time of interval start.
- "end"
Time of interval end.
- "options"
PKNCA.options governing calculations.
For the current group:
- "conc.group"
Concentration measurements for the current group.
- "time.group"
Times associated with concentration measurements for the current group (values start at 0 at the beginning of the current interval).
- "volume.group"
Volume associated with concentration measurements for the current interval (typically applies for excretion parameters like urine).
- "duration.conc.group"
Durations assocuated with concentration measurements for the current group.
- "dose.group"
Dose amounts assocuated with the current group.
- "time.dose.group"
Time of dose start associated with the current group (values start at 0 at the beginning of the current interval).
- "duration.dose.group"
Duration of dose (typically infusion duration) for doses in the current group.
- "route.group"
Route of dosing for the current group.
Value
NULL (Calling this function has a side effect of changing theavailable intervals for calculations)
See Also
Other Interval specifications:check.interval.deps(),check.interval.specification(),choose.auc.intervals(),get.interval.cols(),get.parameter.deps()
Examples
## 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.
Description
Add a hash and associated information to enable checking object provenance.
Usage
addProvenance(object, replace = FALSE)Arguments
object | The object to add provenance |
replace | Replace provenance if the object already has a provenanceattribute. (If the object already has provenance and |
Value
The object with provenance as an added item
See Also
Add the imputation column to the intervals, if it is not already there
Description
Add the imputation column to the intervals, if it is not already there
Usage
add_impute_to_intervals(object)Arguments
object | The PKNCAdata object to impute data within |
Value
The PKNCAdata object with an impute column added to the intervals (ifit is not already there) and the object$impute set to that column name
Calculate the adjusted r-squared value
Description
Calculate the adjusted r-squared value
Usage
adj.r.squared(r.sq, n)Arguments
r.sq | The r-squared value |
n | The number of points |
Value
The numeric adjusted r-squared value
Determine if there are any sparse or dense calculations requested within an interval
Description
Determine if there are any sparse or dense calculations requested within an interval
Usage
any_sparse_dense_in_interval(interval, sparse)Arguments
interval | An interval specification |
sparse | Are the concentration-time data sparse PK (commonly used insmall nonclinical species or with terminal or difficult sampling) or densePK (commonly used in clinical studies or larger nonclinical species)? |
Value
A logical value indicating if the interval requests any sparse (ifsparse=TRUE) or dense (ifsparse=FALSE) calculations.
Extract the parameter results from a PKNCAresults and return them as adata.frame.
Description
Extract the parameter results from a PKNCAresults and return them as adata.frame.
Usage
## S3 method for class 'PKNCAresults'as.data.frame( x, ..., out_format = c("long", "wide"), filter_requested = FALSE, filter_excluded = FALSE, out.format = deprecated())Arguments
x | The object to extract results from |
... | Ignored (for compatibility with generic |
out_format | Should the output be 'long' (default) or 'wide'? |
filter_requested | Only return rows with parameters that werespecifically requested? |
filter_excluded | Should excluded values be removed? |
out.format | Deprecated in favor of |
Value
A data.frame (or usually a tibble) of results
Convert an object into a PKNCAconc object
Description
Convert an object into a PKNCAconc object
Usage
as_PKNCAconc(x, ...)as_PKNCAdose(x, ...)as_PKNCAdata(x, ...)as_PKNCAresults(x, ...)Arguments
x | The object to convert |
... | Passed to subsequent methods |
Value
A converted object
Functions
as_PKNCAdose(): Convert an object into a PKNCAdose objectas_PKNCAdata(): Convert an object into a PKNCAdata objectas_PKNCAresults(): Convert an object into a PKNCAresults object
Generate a sparse_pk object
Description
Generate a sparse_pk object
Usage
as_sparse_pk(conc, time, subject)Arguments
conc | Measured concentrations |
time | Time of the measurement of the concentrations |
subject | Subject identifiers (may be any class; may not be null) |
Value
A sparse_pk object which is a list of lists. The inner lists haveelements named: "time", The time of measurement; "conc", The concentrationmeasured; "subject", The subject identifiers. The object will usually bemodified by future functions to add more named elements to the inner list.
See Also
Other Sparse Methods:pk.calc.sparse_auc(),sparse_auc_weight_linear(),sparse_mean()
Assert that an object is a PKNCAdata object
Description
Assert that an object is a PKNCAdata object
Usage
assert_PKNCAdata(object)Arguments
object | The PKNCAdata object |
Value
The PKNCAdata object (confirmed to be usable)
Assert that a value is a valid AUC method
Description
Assert that a value is a valid AUC method
Usage
assert_aucmethod(method = c("lin up/log down", "linear", "lin-log"))Arguments
method | The method for integration (one of 'lin up/log down','lin-log', or 'linear') |
Value
method or an informative error
Verify that concentration measurements are valid
Description
If the concentrations or times are invalid, will provide an error.Reasons for being invalid are
timeis not a numberconcis not a numberAny
timevalue is NAtimeis not monotonically increasingconcandtimeare not the same length
Usage
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)Arguments
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? |
Details
Some cases may generate warnings but allow the data to proceed.
A negative concentration is often but not always anerror; it will generate a warning.
Value
conc or give an informative error
time or give an informative error
A data.frame with columns named "conc" and "time" or an informativeerror
Assert that a value is a dosing interval
Description
Assert that a value is a dosing interval
Usage
assert_dosetau(tau)Arguments
tau | The dosing interval |
Value
tau or an informative error
Assert Intervals
Description
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 ofthe PKNCAdata object or that they are one of the NCA parameters allowed(i.e. names(get.interval.cols())).It will return the intervals argument unchanged, or it will raise an error.
Usage
assert_intervals(intervals, data)Arguments
intervals | Proposed intervals |
data | PKNCAdata object |
Value
The intervals argument unchanged, or it will raise an error.
Assert that an interval is accurately defined as an interval, and return theinterval
Description
Assert that an interval is accurately defined as an interval, and return theinterval
Usage
assert_intervaltime_single(interval = NULL, start = NULL, end = NULL)Arguments
interval | Numeric vector of two numbers for the start and end time ofintegration |
start | The start time of the interval |
end | The end time of the interval |
Value
interval (orc(start, end))
Assert that a lambda.z value is valid
Description
Assert that a lambda.z value is valid
Usage
assert_lambdaz( lambda.z, any.missing = TRUE, .var.name = checkmate::vname(lambda.z))Arguments
lambda.z | The elimination rate (in units of inverse time) forextrapolation |
any.missing | [ |
.var.name | [ |
Value
lambda.z or an informative error
Confirm that a value is greater than another value
Description
Confirm that a value is greater than another value
Usage
assert_number_between( x, ..., na.ok = FALSE, len = 1, .var.name = checkmate::vname(x))Arguments
x | [any] |
... | Passed to |
na.ok | [ |
len | Ignored (must be 1) |
.var.name | [ |
Value
x or an informative error
Confirm that a value is greater than another value
Description
Confirm that a value is greater than another value
Usage
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))Arguments
x | [any] |
any.missing | [ |
null.ok | [ |
lower_eq,upper_eq | Values where equality is not allowed |
lower | [ |
upper | [ |
... | Passed to |
.var.name | [ |
Value
x
Assert that a value may either be a column name in the data (first) or asingle unit value (second)
Description
Assert that a value may either be a column name in the data (first) or asingle unit value (second)
Usage
assert_unit_col(unit, data)assert_unit_value(unit)assert_unit(unit, data)Arguments
unit | The column name or unit value |
data | The data.frame that contains a column named |
Value
unit with an attribute of "unit_type" that is either "column" or"value", orNULL ifis.null(unit)
Functions
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 unitThe function does not verify that it is a real unit like "ng/mL" only that itis a single character string.
Support function for AUC integration
Description
Support function for AUC integration
Usage
auc_integrate( conc, time, clast, tlast, lambda.z, interval_method, fun_linear, fun_log, fun_inf)Arguments
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) forextrapolation |
interval_method | The method for integrating each interval of |
fun_linear | The function to use for integration of the linear part ofthe curve (not required for AUC or AUMC functions) |
fun_log | The function to use for integration of the logarithmic part ofthe curve (if log integration is used; not required for AUC or AUMCfunctions) |
fun_inf | The function to use for extrapolation from the finalmeasurement to infinite time (not required for AUC or AUMC functions. |
Generate functions to do the named function (e.g. mean) applyingthe business rules.
Description
Generate functions to do the named function (e.g. mean) applyingthe business rules.
Usage
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, ...)Arguments
x | vector to be passed to the various functions |
... | Additional arguments to be passed to the underlying function. |
Value
The value of the various functions or NA if too many values aremissing
Functions
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.
See Also
Check that the conversion to a data type does not change the numberof NA values
Description
Check that the conversion to a data type does not change the numberof NA values
Usage
check.conversion(x, FUN, ...)Arguments
x | the value to convert |
FUN | the function to use for conversion |
... | arguments passed to |
Value
FUN(x, ...) or an error if the set of NAs change.
Take in a single row of an interval specification and return that row updatedwith any additional calculations that must be done to fulfill alldependencies.
Description
Take in a single row of an interval specification and return that row updatedwith any additional calculations that must be done to fulfill alldependencies.
Usage
check.interval.deps(x)Arguments
x | A data frame with one or more rows of the PKNCA interval |
Value
The interval specification with additional calculations added whererequested outputs require them.
See Also
Other Interval specifications:add.interval.col(),check.interval.specification(),choose.auc.intervals(),get.interval.cols(),get.parameter.deps()
Check the formatting of a calculation interval specification data frame.
Description
Calculation interval specifications are data frames defining whatcalculations 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.
Usage
check.interval.specification(x)Arguments
x | The data frame specifying what to calculate during each timeinterval |
Details
start andend time must always be given as columns, and thestart mustbe before theend. Other columns define the parameters to be calculatedand the groupings to apply the intervals to.
Value
x The potentially updated data frame with the interval calculationspecification.
See Also
The vignette "Selection of Calculation Intervals"
Other Interval specifications:add.interval.col(),check.interval.deps(),choose.auc.intervals(),get.interval.cols(),get.parameter.deps()
Check the hash of an object to confirm its provenance.
Description
Check the hash of an object to confirm its provenance.
Usage
checkProvenance(object)Arguments
object | The object to check provenance for |
Value
TRUE if the provenance is confirmed to be consistent,FALSE ifthe provenance is not consistent, orNA if provenance is not present.
See Also
Choose intervals to compute AUCs from time and dosing information
Description
Intervals for AUC are selected by the following metrics:
If only one dose is administered, use the
PKNCA.options("single.dose.aucs")If more than one dose is administered, estimate the AUCbetween any two doses that have PK taken at both of thedosing times and at least one time between the doses.
For the final dose of multiple doses, try to determine thedosing interval (
\tau) and estimate the AUC in thatinterval if multiple samples are taken in the interval.If there are samples
> \tauafter the last dose,calculate the half life after the last dose.
Usage
choose.auc.intervals( time.conc, time.dosing, options = list(), single.dose.aucs = NULL)Arguments
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. |
Value
A data frame with columns forstart,end,auc.type, andhalf.life. Seecheck.interval.specification() for column definitions.The data frame may have zero rows if no intervals could be found.
See Also
pk.calc.auc(),pk.calc.aumc(),pk.calc.half.life(),PKNCA.options()
Other Interval specifications:add.interval.col(),check.interval.deps(),check.interval.specification(),get.interval.cols(),get.parameter.deps()
Other Interval determination:find.tau()
Choose how to interpolate, extrapolate, or integrate data in eachconcentration interval
Description
Choose how to interpolate, extrapolate, or integrate data in eachconcentration interval
Usage
choose_interval_method(conc, time, tlast, method, auc.type, options)Arguments
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 |
Value
A character vector of methods for interpolation/extrapolationmethods that is the same length asconc which indicates how tointerpolate/integrate between each of the concentrations (all but the lastvalue in the vector) and how to extrapolate aftertlast (the last item inthe vector). Possible values in the vector are: 'zero', 'linear', 'log',and 'extrap_log'
Handle BLQ values in the concentration measurements as requested by the user.
Description
Handle BLQ values in the concentration measurements as requested by the user.
Usage
clean.conc.blq( conc, time, ..., options = list(), conc.blq = NULL, conc.na = NULL, check = TRUE)Arguments
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 |
Details
NA concentrations (and their associated times) will be handled asdescribed inclean.conc.na() before working with the BLQ values. Themethod for handling NA concentrations can affect the output of which pointsare considered BLQ and which are considered "middle". Values areconsidered BLQ if they are 0.
conc.blq can be set either a scalar indicating what should be done forall 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:
- first
Values up to the first non-BLQ value. Notethat if all values are BLQ, this includes all values.
- middle
Values that are BLQ between the first and lastnon-BLQ values.
- last
Values that are BLQ after the last non-BLQ value
- before.tmax
Values that are BLQ before the time at first maximum concentration
- after.tmax
Values that are BLQ after the time at first maximum concentration
The valid settings for each are:
- "drop"
Drop the BLQ values
- "keep"
Keep the BLQ values
- a number
Set the BLQ values to that number
Value
The concentration and time measurements (data frame) filtered andcleaned as requested relative to BLQ in the middle.
See Also
Other Data cleaners:clean.conc.na()
Handle NA values in the concentration measurements as requested by the user.
Description
NA concentrations (and their associated times) will be removed then the BLQvalues in the middle
Usage
clean.conc.na(conc, time, ..., options = list(), conc.na = NULL, check = TRUE)Arguments
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 toimpute. |
check |
Value
The concentration and time measurements (data frame) filteredand cleaned as requested relative to NA in the concentration.
See Also
Other Data cleaners:clean.conc.blq()
Calculate the covariance for two time points with sparse sampling
Description
The calculation follows equation A3 in Holder 2001 (see references below):
Usage
cov_holder(sparse_pk)Arguments
sparse_pk | A sparse_pk object from |
Details
\hat{\sigma}_{ij} = \sum\limits_{k=1}^{r_{ij}}{\frac{\left(x_{ik} - \bar{x}_i\right)\left(x_{jk} - \bar{x}_j\right)}{\left(r_{ij} - 1\right) + \left(1 - \frac{r_{ij}}{r_i}\right)\left(1 - \frac{r_{ij}}{r_j}\right)}}
Ifr_{ij} = 0, then\hat{\sigma}_{ij} isdefined as zero (rather than dividing by zero).
Where:
\hat{\sigma}_{ij}The covariance of times i and j
r_iandr_jThe number of subjects (usually animals) at times i and j, respectively
r_{ij}{r_ij}The number of subjects (usually animals) at both times i and j
x_{ik}andx_{jk}The concentration measured for animal k at times i and j, respectively
\bar{x}_iand\bar{x}_jThe mean of the concentrations at times i and j, respectively
The Cauchy-Schwartz inequality is enforced for covariances to keepcorrelation coefficients between -1 and 1, inclusive, as described inequations 8 and 9 of Nedelman and Jia 1998.
Value
A matrix with one row and one column for each element ofsparse_pk_attribute. The covariances are on the off diagonals, and forsimplicity of use, it also calculates the variance on the diagonalelements.
References
Holder DJ. Comments on Nedelman and Jia’s Extension of Satterthwaite’sApproximation Applied to Pharmacokinetics. Journal of BiopharmaceuticalStatistics. 2001;11(1-2):75-79. doi:10.1081/BIP-100104199
Nedelman JR, Jia X. An extension of Satterthwaite’s approximation applied topharmacokinetics. Journal of Biopharmaceutical Statistics. 1998;8(2):317-328.doi:10.1080/10543409808835241
The following functions are defunct
Description
The following functions are defunct
Usage
check.conc.time(...)Arguments
... | Ignored |
Functions
check.conc.time(): Defunct as of version 0.11
Exclude data points or results from calculations or summarization.
Description
Exclude data points or results from calculations or summarization.
Usage
exclude(object, reason, mask, FUN)## Default S3 method:exclude(object, reason, mask, FUN)Arguments
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 (seedetails). |
FUN | A function to operate on the data (one group at a time) to selectreasons for exclusions (see details). |
Details
Only one ofmask orFUN may be given. IfFUN is given, itwill be called with two arguments: a data.frame (or similar object) thatconsists of a single group of the data and the full object (e.g. thePKNCAconc object),FUN(current_group, object), and it must return alogical vector equivalent tomask or a character vector with the reasontext given when data should be excluded orNA_character_ when the datashould be included (for the current exclusion test).
Value
The object with updated information in the exclude column. Theexclude column will contain thereason ifmask orFUN indicate. If aprevious reason for exclusion was given, then subsequent reasons forexclusion will be added to the first with a semicolon space ("; ")separator.
Methods (by class)
exclude(default): The general case for data exclusion
See Also
Other Result exclusions:exclude_nca
Examples
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.
Description
Exclude NCA parameters based on examining the parameter set.
Usage
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()Arguments
min.span.ratio | The minimum acceptable span ratio (uses |
max.aucinf.pext | The maximum acceptable percent AUC extrapolation (uses |
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 |
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 |
Functions
exclude_nca_span.ratio(): Exclude based on span.ratioexclude_nca_max.aucinf.pext(): Exclude based on AUC percent extrapolated (both observed and predicted)exclude_nca_count_conc_measured(): Exclude AUC measurements based on count of concentrations measured and not below the lower limit of quantificationexclude_nca_min.hl.r.squared(): Exclude based on half-life r-squaredexclude_nca_min.hl.adj.r.squared(): Exclude based on half-life adjusted r-squaredexclude_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 fortmax_early = 0)
See Also
Other Result exclusions:exclude()
Examples
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 NCA Results Based on Parameter Thresholds
Description
Exclude rows from NCA results based on specified thresholds for a given parameter.This function allows users to define minimum and/or maximum acceptable valuesfor a parameter and excludes rows that fall outside these thresholds.
Usage
exclude_nca_by_param( parameter, min_thr = NULL, max_thr = NULL, affected_parameters = parameter)Arguments
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. |
Value
A function that can be used withPKNCA::exclude to mark through the 'exclude' columnthe rows in the PKNCA results based on the specified thresholds for a parameter.
Examples
# Example datasetmy_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 2excluded_result <- PKNCA::exclude( my_result, FUN = exclude_nca_by_param("span.ratio", min_thr = 2))as.data.frame(excluded_result)dplyr filtering for PKNCA
Description
dplyr filtering for PKNCA
Usage
## S3 method for class 'PKNCAresults'filter(.data, ..., .preserve = FALSE)## S3 method for class 'PKNCAconc'filter(.data, ..., .preserve = FALSE)## S3 method for class 'PKNCAdose'filter(.data, ..., .preserve = FALSE)Arguments
.data | A data frame, data frame extension (e.g. a tibble), or alazy data frame (e.g. from dbplyr or dtplyr). SeeMethods, below, formore details. |
... | < |
.preserve | Relevant when the |
See Also
Other dplyr verbs:group_by.PKNCAresults(),inner_join.PKNCAresults(),mutate.PKNCAresults()
Find the repeating interval within a vector of doses
Description
This is intended to find the interval over which x repeats by the ruleunique(mod(x, interval)) is minimized.
Usage
find.tau(x, na.action = stats::na.omit, options = list(), tau.choices = NULL)Arguments
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 intervals to look for if the doses are not all equallyspaced. |
Value
A scalar indicating the repeating interval with the most repetition.
If all values are
NAthen NA is returned.If all values are the same, then 0 is returned.
If all values are equally spaced, then that spacing isreturned.
If one of the
choicescan minimize the number ofunique values, then that is returned.If none of the
choicescan minimize the number ofunique values, then -1 is returned.
See Also
Other Interval determination:choose.auc.intervals()
Find the first occurrence of an operator in a formula and returnthe left, right, or both sides of the operator.
Description
Find the first occurrence of an operator in a formula and returnthe left, right, or both sides of the operator.
Usage
findOperator(x, op, side)Arguments
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'. |
Value
The side of the operator requested, NA if requesting the left sideof a unary operator, and NULL if the operator is not found.
See Also
Other Formula parsing:parse_formula_to_cols()
Perform the half-life fit given the data. The function simply fitsthe data without any validation. No selection of points or any othercomponents are done.
Description
Perform the half-life fit given the data. The function simply fitsthe data without any validation. No selection of points or any othercomponents are done.
Usage
fit_half_life(data, tlast, conc_units)Arguments
data | The data to fit. Must have two columns named "log_conc"and "time" |
tlast | The time of last observed concentration above the limitof quantification. |
conc_units | NULL or the units to set for concentration measures |
Value
A data.frame with one row and columns named "r.squared","adj.r.squared", "PROB", "lambda.z", "clast.pred","lambda.z.n.points", "half.life", "span.ratio"
See Also
Extract the formula from a PKNCAconc object.
Description
Extract the formula from a PKNCAconc object.
Usage
## S3 method for class 'PKNCAconc'formula(x, ...)## S3 method for class 'PKNCAdose'formula(x, ...)Arguments
x | The object to extract the formula from. |
... | Unused |
Value
A formula object
Compute the geometric mean, sd, and CV
Description
Compute the geometric mean, sd, and CV
Usage
geomean(x, na.rm = FALSE)geosd(x, na.rm = FALSE)geocv(x, na.rm = FALSE)Arguments
x | A vector to compute the geometric mean of |
na.rm | Should missing values be removed? |
Value
The scalar value of the geometric mean, geometric standard deviation,or geometric coefficient of variation.
Functions
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.
References
Kirkwood T. B.L. Geometric means and measures of dispersion.Biometrics 1979; 35: 908-909
Examples
geomean(1:3)geosd(1:3)geocv(1:3)Extract the best model from a list of models using the AIC.
Description
Extract the best model from a list of models using the AIC.
Usage
get.best.model(object, ...)Arguments
object | the list of models |
... | Parameters passed to AIC.list |
Value
The model which is assessed as best. If more than one are equal,the first is chosen.
Get the first model from a list of models
Description
Get the first model from a list of models
Usage
get.first.model(object)Arguments
object | the list of (lists of, ...) models |
Value
The first item in theobject that is not a list orNA. IfNAis passed in or the list (of lists) is allNA, thenNA is returned.
Get the columns that can be used in an interval specification
Description
Get the columns that can be used in an interval specification
Usage
get.interval.cols()Value
A list with named elements for each parameter. Each list elementcontains the parameter definition.
See Also
check.interval.specification() and the vignette "Selection ofCalculation Intervals"
Other Interval specifications:add.interval.col(),check.interval.deps(),check.interval.specification(),choose.auc.intervals(),get.parameter.deps()
Examples
get.interval.cols()Get all columns that depend on a parameter
Description
Get all columns that depend on a parameter
Usage
get.parameter.deps(x)Arguments
x | The parameter name (as a character string) |
Value
A character vector of parameter names that depend on the parameterx. If none depend onx, then the result will be an empty vector.
See Also
Other Interval specifications:add.interval.col(),check.interval.deps(),check.interval.specification(),choose.auc.intervals(),get.interval.cols()
Retrieve the value of an attribute column.
Description
Retrieve the value of an attribute column.
Usage
getAttributeColumn(object, attr_name, warn_missing = c("attr", "column"))Arguments
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". |
Value
The value of the attribute (orNULL if the attribute is not set orthe column does not exist)
Get the value from a column in a data frame if the value is a columnthere, otherwise, the value should be a scalar or the length of thedata.
Description
Get the value from a column in a data frame if the value is a columnthere, otherwise, the value should be a scalar or the length of thedata.
Usage
getColumnValueOrNot(data, value, prefix = "X")Arguments
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 asthe full column name if it is not already in the dataset or it will beprepended to the maximum column name if not.) |
Value
A list with elements named "data", "name" giving thedata with acolumn named "name" with the value in that column.
Get the name of the element containing the data for the currentobject.
Description
Get the name of the element containing the data for the currentobject.
Usage
## 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)Arguments
object | The object to get the data name from. |
Value
A character scalar with the name of the data object (orNULL if themethod does not apply).
Methods (by class)
getDataName(default): If no data name exists, returns NULL.
See Also
Other PKNCA object extractors:getDepVar(),getIndepVar()
Get the dependent variable (left hand side of the formula) from aPKNCA object.
Description
Get the dependent variable (left hand side of the formula) from aPKNCA object.
Usage
getDepVar(x, ...)Arguments
x | The object to extract the formula from |
... | Unused |
Value
The vector of the dependent variable from the object.
See Also
Other PKNCA object extractors:getDataName.PKNCAconc(),getIndepVar()
Get the groups (right hand side after the| from a PKNCAobject).
Description
Get the groups (right hand side after the| from a PKNCAobject).
Get the groups (right hand side after the| from a PKNCAobject).
Usage
## 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(object$data$conc), level, data = object$result, sep)Arguments
object | The object to extract the data from |
form | The formula to extract the data from (defaults to the formulafrom |
level | optional. If included, this specifies the level(s) of thegroups 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 |
Value
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) froma PKNCA object.
Description
Get the independent variable (right hand side of the formula) froma PKNCA object.
Usage
getIndepVar(x, ...)Arguments
x | The object to extract the formula from |
... | Unused |
Value
The vector of the independent variable from the object.
See Also
Other PKNCA object extractors:getDataName.PKNCAconc(),getDepVar()
Determine which concentrations were used for half-life calculation
Description
Determine which concentrations were used for half-life calculation
Usage
get_halflife_points(object)Arguments
object | A PKNCAresults object |
Value
A logical vector withTRUE if the point was used for half-life(including concentrations below the limit of quantification within therange of times for calculation),FALSE if it was not used for half-lifebut the half-life was calculated for the interval, andNA if half-lifewas not calculated for the interval. If a row is excluded from allcalculations, it is set toNA as well.
Examples
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 the impute function from either the intervals column or from the method
Description
Get the impute function from either the intervals column or from the method
Usage
get_impute_method(intervals, impute)Arguments
intervals | the data.frame of intervals |
impute | the imputation definition |
Value
The imputation function vector
dplyr grouping for PKNCA
Description
dplyr grouping for PKNCA
Usage
## 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, ...)Arguments
.data | A data frame, data frame extension (e.g. a tibble), or alazy data frame (e.g. from dbplyr or dtplyr). SeeMethods, below, formore details. |
... | In |
.add | When This argument was previously called |
.drop | Drop groups formed by factor levels that don't appear in thedata? The default is |
x |
See Also
Other dplyr verbs:filter.PKNCAresults(),inner_join.PKNCAresults(),mutate.PKNCAresults()
Get grouping variables for a PKNCA object
Description
Get grouping variables for a PKNCA object
Usage
## 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)Arguments
x | The PKNCA object |
Value
A character vector (possibly empty) of the grouping variables
Functions
group_vars(PKNCAdata): Get group_vars for a PKNCAdata objectfrom the PKNCAconc object withingroup_vars(PKNCAdose): Get group_vars for a PKNCAdose objectgroup_vars(PKNCAresults): Get group_vars for a PKNCAresults objectfrom the PKNCAconc object within
dplyr joins for PKNCA
Description
dplyr joins for PKNCA
Usage
## 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)Arguments
x,y | A pair of data frames, data frame extensions (e.g. a tibble), orlazy data frames (e.g. from dbplyr or dtplyr). SeeMethods, below, formore 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 vectorof 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
|
See Also
Other dplyr verbs:filter.PKNCAresults(),group_by.PKNCAresults(),mutate.PKNCAresults()
Interpolate concentrations between measurements or extrapolate concentrationsafter the last measurement.
Description
interpolate.conc() andextrapolate.conc() returns an interpolated (orextrapolated) concentration.interp.extrap.conc() will choose whetherinterpolation or extrapolation is required and will also operate on manyconcentrations. These will typically be used to estimate the concentrationbetween two measured concentrations or after the last measured concentration.Of note, these functions will not extrapolate prior to the first point.
Usage
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)Arguments
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) forextrapolation |
clast | The last observed concentration above the limit ofquantification. 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 BLQ values. (See |
conc.na | How to handle NA concentrations. (See |
check | |
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 detailsfor how this parameter is used. |
out.after | Should interpolation occur from the data before ( |
Details
AnNA value for thelambda.z parameter will prevent extrapolation.
- extrap.method
- 'AUCinf'
Use lambda.z to extrapolate beyond the last point with the half-life.
- 'AUCall'
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.
- 'AUClast'
Extrapolates all points after the last above the limit of quantification as 0.
duration.dose anddirection.out are ignored ifroute.dose == "extravascular".direction.out is ignored ifduration.dose > 0.
route.dose andduration.dose affect how interpolation/extrapolation ofthe concentration occurs at the time of dosing. Ifroute.dose == "intravascular" andduration.dose == 0 then extrapolation occurs for an IVbolus usingpk.calc.c0() with the data after dosing. Otherwise (eitherroute.dose == "extravascular" orduration.dose > 0), extrapolation occursusing the concentrations before dosing and estimating the half-life (or moreprecisely, estimatinglambda.z). Finally,direction.out can change thedirection of interpolation in cases withroute.dose == "intravascular" andduration.dose == 0. Whendirection.out == "before" interpolation occursonly with data before the dose (as is the case forroute.dose == "extravascular"), but ifdirection.out == "after" interpolation occursfrom the data after dosing.
Value
The interpolated or extrapolated concentration value as a scalardouble (or vector forinterp.extrap.conc()).
Functions
interpolate.conc(): Interpolate concentrations through Tlast (inclusive)extrapolate.conc(): Extrapolate concentrations after Tlastinterp.extrap.conc.dose(): Interpolate and extrapolate concentrationswithout interpolating or extrapolating beyond doses.
See Also
pk.calc.clast.obs(),pk.calc.half.life(),pk.calc.c0()
Interpolate or extrapolate concentrations using the provided method
Description
Interpolate or extrapolate concentrations using the provided method
Usage
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)Arguments
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) forextrapolation |
tlast | The time of the last concentration above the lower limit ofquantification (LOQ) |
Value
The interpolated or extrapolated value using the correct method
Is a PKNCA object used for sparse PK?
Description
Is a PKNCA object used for sparse PK?
Usage
## 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)Arguments
object | The object to see if it includes sparse PK |
Value
TRUE if sparse andFALSE if dense (not sparse)
Extract the columns used in the formula (in order) from a PKNCAconcor PKNCAdose object.
Description
Extract the columns used in the formula (in order) from a PKNCAconcor PKNCAdose object.
Usage
## S3 method for class 'PKNCAconc'model.frame(formula, ...)## S3 method for class 'PKNCAdose'model.frame(formula, ...)Arguments
formula | The object to use (parameter name is |
... | Unused |
Value
A data frame with the columns from the object in formula order.
dplyr mutate-based modification for PKNCA
Description
dplyr mutate-based modification for PKNCA
Usage
## S3 method for class 'PKNCAresults'mutate(.data, ...)## S3 method for class 'PKNCAconc'mutate(.data, ...)## S3 method for class 'PKNCAdose'mutate(.data, ...)Arguments
.data | A data frame, data frame extension (e.g. a tibble), or alazy data frame (e.g. from dbplyr or dtplyr). SeeMethods, below, formore details. |
... | < The value can be:
|
See Also
Other dplyr verbs:filter.PKNCAresults(),group_by.PKNCAresults(),inner_join.PKNCAresults()
Normalize the exclude column by setting blanks to NA
Description
Normalize the exclude column by setting blanks to NA
Usage
normalize_exclude(object)Arguments
object | The object to extract the exclude column from |
Value
The exclude vector whereNA indicates not to exclude and anythingelse indicates to exclude.
Convert a formula representation to the columns for input data
Description
Convert a formula representation to the columns for input data
Usage
parse_formula_to_cols(form)Arguments
form | the formula (or something coercible into a formula) to extractinto its parts |
Value
A list of column names for various formula parts
See Also
Other Formula parsing:findOperator()
Run any function with a maximum missing fraction of X and 0s possiblycounting as missing. The maximum fraction missing comes fromPKNCA.options("max.missing").
Description
Note that all missing values are removed prior to calling the function.
Usage
pk.business(FUN, zero.missing = FALSE, max.missing)Arguments
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 (anumber between 0 and 1, inclusive). |
Value
A version of FUN that can be called with parameters that are checkedfor missingness (and zeros) with missing (and zeros) removed before thecall. Ifmax.missing is exceeded, then NA is returned.
Examples
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 valuemy_mean(c(1:3, rep(NA, 4)))Calculate amount excreted (typically in urine or feces)
Description
Calculate amount excreted (typically in urine or feces)
Usage
pk.calc.ae(conc, volume, check = TRUE)Arguments
conc | Measured concentrations |
volume | The volume (or mass) of the sample |
check | Should the concentration and volume data be checked? |
Details
ae issum(conc*volume).
The units for the concentration and volume should match such thatsum(conc*volume) has units of mass or moles.
Value
The amount excreted during the interval
See Also
Calculate the AUC above a given concentration
Description
Concentrations below the given concentration (conc_above) will be setto zero.
Usage
pk.calc.aucabove(conc, time, conc_above = NA_real_, ..., options = list())Arguments
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 usedis |
options | List of changes to the default PKNCA options (see |
Value
The AUC of the concentration above the limit
Calculate the AUC over an interval with interpolation and/orextrapolation of concentrations for the beginning and end of theinterval.
Description
Calculate the AUC over an interval with interpolation and/orextrapolation of concentrations for the beginning and end of theinterval.
Usage
pk.calc.aucint( 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, method = NULL, auc.type = "AUClast", conc.blq = NULL, conc.na = NULL, check = TRUE, ..., options = list())pk.calc.aucint.last( conc, time, start = NULL, end = NULL, time.dose, ..., options = list())pk.calc.aucint.all( conc, time, start = NULL, end = NULL, time.dose, ..., options = list())pk.calc.aucint.inf.obs( conc, time, start = NULL, end = NULL, time.dose, lambda.z, clast.obs, ..., options = list())pk.calc.aucint.inf.pred( conc, time, start = NULL, end = NULL, time.dose, lambda.z, clast.pred, ..., options = list())Arguments
conc | Measured concentrations |
time | Time of the measurement of the concentrations |
interval | Numeric vector of two numbers for the start and end time ofintegration |
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 ofquantification; this is used for AUCinf calculations. If provided asclast.obs (observed clast value, default), AUCinf is AUCinf,obs. Ifprovided as clast.pred, AUCinf is AUCinf,pred. |
lambda.z | The elimination rate (in units of inverse time) forextrapolation |
time.dose,route,duration.dose | The time of doses, route ofadministration, and duration of dose used with interpolation andextrapolation of concentration data (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'. |
conc.blq | How to handle BLQ values in between the first and last aboveLOQ concentrations. (See |
conc.na | How to handle missing concentration values. (See |
check | |
... | Additional arguments passed to |
options | List of changes to the default PKNCA options (see |
Details
Whenpk.calc.aucint() needs to extrapolate usinglambda.z (in otherwords, using the half-life), it will always extrapolate using the logarithmictrapezoidal rule to align with using a half-life calculation for theextrapolation.
Value
The AUC for an interval of time as a number
Functions
pk.calc.aucint.last(): Interpolate or extrapolate concentrations forAUClastpk.calc.aucint.all(): Interpolate or extrapolate concentrations forAUCallpk.calc.aucint.inf.obs(): Interpolate or extrapolate concentrations forAUCinf.obspk.calc.aucint.inf.pred(): Interpolate or extrapolate concentrations forAUCinf.pred
See Also
PKNCA.options(),interp.extrap.conc.dose()
Other AUC calculations:pk.calc.auxc()
Calculate AUC for intravenous dosing
Description
Calculate AUC for intravenous dosing
Usage
pk.calc.auciv(conc, time, c0, auc, ..., options = list(), check = TRUE)pk.calc.auciv_pbext(auc, auciv)Arguments
conc | Measured concentrations |
time | Time of the measurement of the concentrations |
c0 | The concentration at time 0, typically calculated using |
auc | The AUC calculated using |
... | For functions other than |
options | List of changes to the default PKNCA options (see |
check | |
auciv | The AUC calculated using |
Details
The AUC for intravenous (IV) dosing extrapolates the AUC back fromthe first measurement to time 0 using c0 and the AUC calculated by anothermethod (for example the auclast).
The calculation method takes the following steps:
time = 0must be present in the data with a measured concentration.The AUC between
time = 0and the next time point is calculated (auc_first).The AUC between
time = 0withc0and the next time point is calculated (auc_second).The final AUC is the initial AUC plus the difference between the two AUCs (
auc_final <- auc + auc_second - auc_first).
The calculation for back-extrapolation is100*(1 - auc/auciv).
Value
pk.calc.auciv: The AUC calculated usingc0
pk.calc.auciv_pctbackextrap: The AUC percent back-extrapolated
Functions
pk.calc.auciv_pbext(): Calculate the percent back-extrapolated AUC for IVadministration
Calculate the AUC percent extrapolated
Description
Calculate the AUC percent extrapolated
Usage
pk.calc.aucpext(auclast, aucinf)Arguments
auclast | the area under the curve from time 0 to the last measurementabove the limit of quantification |
aucinf | the area under the curve from time 0 to infinity |
Details
aucpext is100*(1-auclast/aucinf).
Value
The numeric value of the AUC percent extrapolated orNA_real_ ifany of the following are trueis.na(aucinf),is.na(auclast),aucinf <= 0, orauclast <= 0.
A compute the Area Under the (Moment) Curve
Description
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 manypurposes when analyzing PK in drug development.
Usage
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())Arguments
conc | Measured concentrations |
time | Time of the measurement of the concentrations |
interval | Numeric vector of two numbers for the start and end time ofintegration |
clast,clast.obs,clast.pred | The last concentration above the limit ofquantification; this is used for AUCinf calculations. If provided asclast.obs (observed clast value, default), AUCinf is AUCinf,obs. Ifprovided as clast.pred, AUCinf is AUCinf,pred. |
lambda.z | The elimination rate (in units of inverse time) forextrapolation |
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 BLQ values in between the first and last aboveLOQ concentrations. (See |
conc.na | How to handle missing concentration values. (See |
check | |
fun_linear | The function to use for integration of the linear part ofthe curve (not required for AUC or AUMC functions) |
fun_log | The function to use for integration of the logarithmic part ofthe curve (if log integration is used; not required for AUC or AUMCfunctions) |
fun_inf | The function to use for extrapolation from the finalmeasurement to infinite time (not required for AUC or AUMC functions. |
... | For functions other than |
Details
pk.calc.auc.last is simply a shortcut setting theintervalparameter toc(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 callpk.calc.auxc(). Usually, you will callone of the other functions for calculating AUC likepk.calc.auc.last(),pk.calc.auc.inf.obs(), etc.
Value
A numeric value for the AU(M)C.
Functions
pk.calc.auc(): Compute the area under the curvepk.calc.auc.last(): Compute the AUClast.pk.calc.auc.inf(): Compute the AUCinfpk.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 curvepk.calc.aumc.last(): Compute the AUMClast.pk.calc.aumc.inf(): Compute the AUMCinfpk.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.
References
Gabrielsson J, Weiner D. "Section 2.8.1 Computation methods - Lineartrapezoidal rule." Pharmacokinetic & Pharmacodynamic Data Analysis: Conceptsand Applications, 4th Edition. Stockholm, Sweden: Swedish PharmaceuticalPress, 2000. 162-4.
Gabrielsson J, Weiner D. "Section 2.8.3 Computation methods - Log-lineartrapezoidal rule." Pharmacokinetic & Pharmacodynamic Data Analysis: Conceptsand Applications, 4th Edition. Stockholm, Sweden: Swedish PharmaceuticalPress, 2000. 164-7.
See Also
Other AUC calculations:pk.calc.aucint()
Examples
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))Estimate the concentration at dosing time for an IV bolus dose.
Description
Estimate the concentration at dosing time for an IV bolus dose.
Usage
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)Arguments
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 | Check the |
Details
Methods available for interpolation are below, and eachhas its own specific function.
c0If the observed
concattime.doseis 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.dosec1Use the first point after
time.dosecminSet 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.
Value
The estimated concentration at time 0.
Functions
pk.calc.c0.method.logslope(): Semilog regress the first and second pointsafter time.dose. This method will returnNAif the secondconcaftertime.doseis 0 or greater than the first.pk.calc.c0.method.c0(): UseC0=conc[time %in% time.dose]if it isnonzero.pk.calc.c0.method.c1(): UseC0=C1.pk.calc.c0.method.set0(): UseC0= 0 (typically used for single dose oral andIV infusion)pk.calc.c0.method.cmin(): UseC0= Cmin (typically used for multiple dose oraland IV infusion but not IV bolus)
Calculate the average concentration during an interval.
Description
Calculate the average concentration during an interval.
Usage
pk.calc.cav(auc, start, end)Arguments
auc | The area under the curve during the interval |
start | The start time of the interval |
end | The end time of the interval |
Details
cav isauc/(end-start).
Value
The Cav (average concentration during the interval)
Determine the concentration at the end of infusion
Description
Determine the concentration at the end of infusion
Usage
pk.calc.ceoi(conc, time, duration.dose = NA, check = TRUE)Arguments
conc | Measured concentrations |
time | Time of the measurement of the concentrations |
duration.dose | The duration for the dosing administration (typicallyfrom IV infusion) |
check |
Value
The concentration at the end of the infusion,NA ifduration.dose isNA, orNA if alltime != duration.dose
Calculate the (observed oral) clearance
Description
Calculate the (observed oral) clearance
Usage
pk.calc.cl(dose, auc)Arguments
dose | the dose administered |
auc | The area under the concentration-time curve. |
Details
cl isdose/auc.
Ifdose is the same length as the other inputs, then the outputwill be the same length as all of the inputs; the function assumes that youare calculating for multiple intervals simultaneously. If the inputs otherthandose are scalars anddose is a vector, then the function assumesmultiple doses were given in a single interval, and the sum of thedoseswill be used for the calculation.
Value
the numeric value of the total (CL) or observed oral clearance(CL/F)
References
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.
Determine the last observed concentration above the limit of quantification(LOQ).
Description
If all concentrations are missing,NA_real_ is returned. If allconcentrations are zero (below the limit of quantification) or missing, zerois returned. If Tlast is NA (due to no non-missing above LOQ measurements),this will returnNA_real_.
Usage
pk.calc.clast.obs(conc, time, check = TRUE)Arguments
conc | Measured concentrations |
time | Time of the measurement of the concentrations |
check |
Value
The last observed concentration above the LOQ
See Also
Other NCA parameters for concentrations during the intervals:pk.calc.cmax(),pk.calc.count_conc(),pk.calc.cstart(),pk.calc.ctrough()
Calculate renal clearance
Description
Calculate renal clearance
Usage
pk.calc.clr(ae, auc)Arguments
ae | The amount excreted in urine (as a numeric scalar or vector) |
auc | The area under the curve (as a numeric scalar or vector) |
Details
clr issum(ae)/auc.
The units for theae andauc should match such thatae/auc hasunits of volume/time.
Value
The renal clearance as a number
See Also
Determine maximum observed PK concentration
Description
Determine maximum observed PK concentration
Usage
pk.calc.cmax(conc, check = TRUE)pk.calc.cmin(conc, check = TRUE)Arguments
conc | Measured concentrations |
check | Run |
Value
a number for the maximum concentration or NA if all concentrationsare missing
Functions
pk.calc.cmin(): Determine the minimum observed PKconcentration
See Also
Other NCA parameters for concentrations during the intervals:pk.calc.clast.obs(),pk.calc.count_conc(),pk.calc.cstart(),pk.calc.ctrough()
Other NCA parameters for concentrations during the intervals:pk.calc.clast.obs(),pk.calc.count_conc(),pk.calc.cstart(),pk.calc.ctrough()
Examples
conc_data <- Theoph[Theoph$Subject == 1,]pk.calc.cmin(conc_data$conc)Count the number of concentration measurements in an interval
Description
count_conc andcount_conc_measured are typically used for quality controlon the data to ensure that there are a sufficient number of non-missingsamples for a calculation and to ensure that data are consistent betweenindividuals.
Usage
pk.calc.count_conc(conc, check = TRUE)pk.calc.count_conc_measured(conc, check = TRUE)Arguments
conc | Measured concentrations |
check | Run |
Value
a count of the non-missing concentrations (0 if all concentrationsare missing)
a count of the non-missing, measured (not below or above the limitof quantification) concentrations (0 if all concentrations are missing)
Functions
pk.calc.count_conc_measured(): Count the number of concentration measurementsthat are not missing, above, or below the limit of quantification in aninterval
See Also
Other NCA parameters for concentrations during the intervals:pk.calc.clast.obs(),pk.calc.cmax(),pk.calc.cstart(),pk.calc.ctrough()
Determine the concentration at the beginning of the interval
Description
Determine the concentration at the beginning of the interval
Usage
pk.calc.cstart(conc, time, start)Arguments
conc | Measured concentrations |
time | Time of the measurement of the concentrations |
start | The start time of the interval |
Value
The concentration whentime == end. If none match, thenNA
See Also
Other NCA parameters for concentrations during the intervals:pk.calc.clast.obs(),pk.calc.cmax(),pk.calc.count_conc(),pk.calc.ctrough()
Determine the trough (end of interval) concentration
Description
Determine the trough (end of interval) concentration
Usage
pk.calc.ctrough(conc, time, end)Arguments
conc | Measured concentrations |
time | Time of the measurement of the concentrations |
end | The end time of the interval |
Value
The concentration whentime == end. If none match, thenNA
See Also
Other NCA parameters for concentrations during the intervals:pk.calc.clast.obs(),pk.calc.cmax(),pk.calc.count_conc(),pk.calc.cstart()
Determine the degree of fluctuation
Description
Determine the degree of fluctuation
Usage
pk.calc.deg.fluc(cmax, cmin, cav)Arguments
cmax | The maximum observed concentration |
cmin | The minimum observed concentration |
cav | The average concentration in the interval |
Details
deg.fluc is100*(cmax - cmin)/cav.
Value
The degree of fluctuation around the average concentration.
Determine dose normalized NCA parameter
Description
Determine dose normalized NCA parameter
Usage
pk.calc.dn(parameter, dose)Arguments
parameter | Parameter to dose normalize |
dose | Dose in units compatible with the area under the curve |
Value
a number for dose normalized AUC
Examples
pk.calc.dn(90, 10)Calculate the absolute (or relative) bioavailability
Description
Calculate the absolute (or relative) bioavailability
Usage
pk.calc.f(dose1, auc1, dose2, auc2)Arguments
dose1 | The dose administered in route or method 1 |
auc1 | The AUC from 0 to infinity or 0 to tau administered in route ormethod 1 |
dose2 | The dose administered in route or method 2 |
auc2 | The AUC from 0 to infinity or 0 to tau administered in route ormethod 2 |
Details
f is(auc2/dose2)/(auc1/dose1).
Calculate fraction excreted (typically in urine or feces)
Description
Calculate fraction excreted (typically in urine or feces)
Usage
pk.calc.fe(ae, dose)Arguments
ae | The amount excreted (as a numeric scalar or vector) |
dose | The dose (as a numeric scalar or vector) |
Details
fe issum(ae)/dose
The units forae anddose should be the same so thatae/doseis a unitless fraction.
Value
The fraction of dose excreted
See Also
Compute the half-life and associated parameters
Description
The terminal elimination half-life is estimated from the final points in theconcentration-time curve using semi-log regression (log(conc)~time)with automated selection of the points for calculation (unlessmanually.selected.points isTRUE).
Usage
pk.calc.half.life( conc, time, tmax, tlast, time.dose = NULL, duration.dose = 0, manually.selected.points = FALSE, options = list(), min.hl.points = NULL, adj.r.squared.factor = NULL, conc.blq = NULL, conc.na = NULL, first.tmax = NULL, allow.tmax.in.half.life = NULL, check = TRUE)Arguments
conc | Measured concentrations |
time | Time of the measurement of the concentrations |
tmax | Time of maximum concentration (will be calculated andincluded in the return data frame if not given) |
tlast | Time of last concentration above the limit ofquantification (will be calculated and included in the return dataframe if not given) |
time.dose | Time of the dose for the current interval (must be the samelength as |
duration.dose | The duration of the dose administration for the currentinterval (typically zero for extravascular and intravascular bolus andnonzero for intravascular infusion) |
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 beincluded to calculate the half-life |
adj.r.squared.factor | The allowance in adjusted r-squared foradding another point. |
conc.blq | |
conc.na | |
first.tmax | See |
allow.tmax.in.half.life | Allow the concentration point for tmaxto be included in the half-life slope calculation. |
check |
Details
See the "Half-Life Calculation" vignette for more details on the calculationmethods used.
Ifmanually.selected.points isFALSE (default), thehalf-life is calculated by computing the best fit line for all points at orafter tmax (based on the value ofallow.tmax.in.half.life). The besthalf-life is chosen by the following rules in order:
At least
min.hl.pointspoints includedA
lambda.z> 0 and at the same time the best adjusted r-squared(withinadj.r.squared.factor)The one with the most points included
Ifmanually.selected.points isTRUE, theconcandtime data are used as-is without any form of selection forthe best-fit half-life.
Value
A data frame with one row and columns for
- tmax
Time of maximum observed concentration (only includedif not given as an input)
- tlast
Time of last observed concentration above the LOQ (onlyincluded if not given as an input)
- r.squared
coefficient of determination
- adj.r.squared
adjusted coefficient of determination
- lambda.z
elimination rate
- lambda.z.time.first
first time for half-life calculation
- lambda.z.time.last
last time for half-life calculation
- lambda.z.n.points
number of points in half-life calculation
- clast.pred
Concentration at tlast as predicted by the half-lifeline
- half.life
half-life
- span.ratio
span ratio [ratio of half-life to time used forhalf-life calculation
References
Gabrielsson J, Weiner D. "Section 2.8.4 Strategies for estimation oflambda-z." Pharmacokinetic & Pharmacodynamic Data Analysis: Conceptsand Applications, 4th Edition. Stockholm, Sweden: SwedishPharmaceutical Press, 2000. 167-9.
Calculate the elimination rate (Kel)
Description
Calculate the elimination rate (Kel)
Usage
pk.calc.kel(mrt)Arguments
mrt | the mean residence time |
kel | is |
Value
the numeric value of the elimination rate
Calculate the mean residence time (MRT) for single-dose data or linearmultiple-dose data.
Description
Calculate the mean residence time (MRT) for single-dose data or linearmultiple-dose data.
Usage
pk.calc.mrt(auc, aumc)pk.calc.mrt.iv(auc, aumc, duration.dose)Arguments
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 durationfor an IV infusion) |
Details
mrt isaumc/auc - duration.dose/2 whereduration.dose = 0 for oral administration.
Value
the numeric value of the mean residence time
Functions
pk.calc.mrt.iv(): MRT for an IV infusion
See Also
Calculate the mean residence time (MRT) for multiple-dose data with nonlinearkinetics.
Description
Calculate the mean residence time (MRT) for multiple-dose data with nonlinearkinetics.
Usage
pk.calc.mrt.md(auctau, aumctau, aucinf, tau)Arguments
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-dosedata) |
tau | The dosing interval |
Details
mrt.md isaumctau/auctau + tau*(aucinf-auctau)/auctau and shouldonly be used for multiple dosing with equal intervals between doses.
Note that ifaucinf == auctau (as would be the assumption withlinear kinetics), the equation becomes the same as the single-dose MRT.
See Also
Determine the peak-to-trough ratio
Description
Determine the peak-to-trough ratio
Usage
pk.calc.ptr(cmax, ctrough)Arguments
cmax | The maximum observed concentration |
ctrough | The last concentration in an interval |
Details
ptr iscmax/ctrough.
Value
The ratio of cmax to ctrough (if ctrough == 0, NA)
Calculate AUC and related parameters using sparse NCA methods
Description
The AUC is calculated as:
Usage
pk.calc.sparse_auc( conc, time, subject, method = NULL, auc.type = "AUClast", ..., options = list())pk.calc.sparse_auclast(conc, time, subject, ..., options = list())Arguments
conc | Measured concentrations |
time | Time of the measurement of the concentrations |
subject | Subject identifiers (may be any class; may not be null) |
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 |
Details
AUC=\sum\limits_{i} w_i \bar{C}_i
Where:
AUCis the estimated area under the concentration-time curve
w_iis the weight applied to the concentration at time i (related to the time which it affects, see
sparse_auc_weight_linear())\bar{C}_iis the average concentration at time i
Functions
pk.calc.sparse_auclast(): Compute the AUClast for sparse PK
See Also
Other Sparse Methods:as_sparse_pk(),sparse_auc_weight_linear(),sparse_mean()
Determine the PK swing
Description
Determine the PK swing
Usage
pk.calc.swing(cmax, cmin)Arguments
cmax | The maximum observed concentration |
cmin | The minimum observed concentration |
Details
swing is100*(cmax - cmin)/cmin.
Value
The swing above the minimum concentration. Ifcmin is zero, thenthe result is infinity.
Calculate the effective half-life
Description
Calculate the effective half-life
Usage
pk.calc.thalf.eff(mrt)Arguments
mrt | the mean residence time to infinity |
Details
thalf.eff islog(2)*mrt.
Value
the numeric value of the effective half-life
Determine time at or above a set value
Description
Interpolation is performed aligning withPKNCA.options("auc.method").Extrapolation outside of the measured times is not yet implemented. Themethod may be changed by giving a namedmethod argument, as well.
Usage
pk.calc.time_above(conc, time, conc_above, ..., options = list(), check = TRUE)Arguments
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 usedis |
options | List of changes to the default PKNCA options (see |
check |
Details
For'lin up/log down', ifclast is aboveconc_above and there areconcentrations BLQ after that, linear down is used to extrapolate to the BLQconcentration (equivalent to AUCall).
Value
the time above the given concentration
Determine the observed lag time (time before the firstconcentration above the limit of quantification or above the firstconcentration in the interval)
Description
Determine the observed lag time (time before the firstconcentration above the limit of quantification or above the firstconcentration in the interval)
Usage
pk.calc.tlag(conc, time)Arguments
conc | Measured concentrations |
time | Time of the measurement of the concentrations |
Value
The time associated with the first increasing concentration
Determine time of last observed concentration above the limit ofquantification.
Description
NA will be returned if allconc areNA or 0.
Usage
pk.calc.tlast(conc, time, check = TRUE)pk.calc.tfirst(conc, time, check = TRUE)Arguments
conc | Measured concentrations |
time | Time of the measurement of the concentrations |
check |
Value
The time of the last observed concentration measurement
Functions
pk.calc.tfirst(): Determine the first concentration abovethe limit of quantification.
Determine time of maximum observed PK concentration
Description
Input restrictions are:
the
concandtimemust be the same length,the
timemay have no NAs,
NA will be returned if:
the length of
concandtimeis 0all
concis 0 orNA
Usage
pk.calc.tmax(conc, time, options = list(), first.tmax = NULL, check = TRUE)Arguments
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 time that matches the maximumconcentration, should the first be considered as Tmax? If not, then thelast is considered Tmax. |
check |
Value
The time of the maximum concentration
Examples
conc_data <- Theoph[Theoph$Subject == 1,]pk.calc.tmax(conc = conc_data$conc, time = conc_data$Time)Extract the dose used for calculations
Description
Extract the dose used for calculations
Usage
pk.calc.totdose(dose)Arguments
dose | the dose administered |
Value
The total dose for an interval
Calculate the steady-state volume of distribution (Vss)
Description
Calculate the steady-state volume of distribution (Vss)
Usage
pk.calc.vss(cl, mrt)Arguments
cl | the clearance |
mrt | the mean residence time |
Details
vss iscl*mrt.
Value
the volume of distribution at steady-state
Calculate the terminal volume of distribution (Vz)
Description
Calculate the terminal volume of distribution (Vz)
Usage
pk.calc.vz(cl, lambda.z)Arguments
cl | the clearance (or apparent observed clearance) |
lambda.z | The elimination rate (in units of inverse time) forextrapolation |
Details
vz iscl/lambda.z.
Compute NCA parameters for each interval for each subject.
Description
Thepk.nca function computes the NCA parameters from aPKNCAdata object.All options for the calculation and input data are set in prior functions(PKNCAconc,PKNCAdose, andPKNCAdata). Options for calculations areset either inPKNCAdata or with the current default options inPKNCA.options.
Usage
pk.nca(data, verbose = FALSE)Arguments
data | A PKNCAdata object |
verbose | Indicate, by |
Details
When performing calculations, all time results are relative to the start ofthe interval. For example, if an interval starts at 168 hours, ends at 192hours, and and the maximum concentration is at 169 hours,tmax=169-168=1.
Value
APKNCAresults object.
See Also
PKNCAdata(),PKNCA.options(),summary.PKNCAresults(),as.data.frame.PKNCAresults(),exclude()
Compute all PK parameters for a single concentration-time data set
Description
For one subject/time range, compute all available PK parameters. All theinternal options should be set byPKNCA.options() prior to running. Theonly part that changes with a call to this function is theconcentrationandtime.
Usage
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, impute_method = NA_character_, include_half.life = NULL, exclude_half.life = NULL, subject, sparse, interval, options = list())Arguments
conc | Measured concentrations |
time | Time of the measurement of the concentrations |
volume,volume.group | The volume (or mass) of the concentrationmeasurement for the current interval or all data for the group (typicallyfor urine and fecal measurements) |
duration.conc,duration.conc.group | The duration of the concentrationmeasurement for the current interval or all data for the group (typicallyfor urine and fecal measurements) |
dose,dose.group | Dose amount (may be a scalar or vector) for thecurrent interval or all data for the group |
time.dose | Time of the dose for the current interval (must be the samelength as |
duration.dose | The duration of the dose administration for the currentinterval (typically zero for extravascular and intravascular bolus andnonzero for intravascular infusion) |
route,route.group | The route of dosing for the current interval or alldata 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 bethe same length as |
duration.dose.group | The duration of the dose administration for alldata for the group (typically zero for extravascular and intravascularbolus and nonzero for intravascular infusion) |
impute_method | The method to use for imputation as a character string |
include_half.life | An optional boolean vector of the concentrationmeasurements to include in the half-life calculation. If given, nohalf-life point selection will occur. |
exclude_half.life | An optional boolean vector of the concentrationmeasurements to exclude from the half-life calculation. |
subject | Subject identifiers (used for sparse calculations) |
sparse | Should only sparse calculations be performed (TRUE) or onlydense calculations (FALSE)? |
interval | One row of an interval definition (see |
options | List of changes to the default PKNCA options (see |
Value
A data frame with the start and end time along with all PKparameters for theinterval
See Also
check.interval.specification()
Compute NCA for multiple intervals
Description
Compute NCA for multiple intervals
Usage
pk.nca.intervals( data_conc, data_dose, data_intervals, sparse, options, impute, verbose = FALSE)Arguments
data_conc | A data.frame or tibble with standardized column names asoutput from |
data_dose | A data.frame or tibble with standardized column names asoutput from |
data_intervals | A data.frame or tibble with standardized column namesas output from |
sparse | Should only sparse calculations be performed (TRUE) or onlydense calculations (FALSE)? |
options | List of changes to the default PKNCA options (see |
impute | The column name in |
verbose | Indicate, by |
Value
A data.frame with all NCA results
Compute the time to steady-state (tss)
Description
Compute the time to steady-state (tss)
Usage
pk.tss(..., type = c("monoexponential", "stepwise.linear"), check = TRUE)Arguments
... | Passed to |
type | The type of Tss to calculate, either |
check |
Value
A data frame with columns as defined frompk.tss.monoexponentialand/orpk.tss.stepwise.linear.
See Also
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 useby the tss calculators.
Description
Clean up the time to steady-state parameters and return a data frame for useby the tss calculators.
Usage
pk.tss.data.prep( conc, time, subject, treatment, subject.dosing, time.dosing, options = list(), conc.blq = NULL, conc.na = NULL, check = TRUE, ...)Arguments
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 assumedto 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 | |
conc.na | |
check | |
... | Discarded inputs to allow generic calls between tss methods. |
Value
a data frame with columns forconcentration,time,subject,andtreatment.
Compute the time to steady state using nonlinear, mixed-effects modeling oftrough concentrations.
Description
Trough concentrations are selected as concentrations at the time of dosing.An exponential curve is then fit through the data with a different magnitudeby treatment (as a factor) and a random steady-state concentration and timeto stead-state by subject (seerandom.effects argument).
Usage
pk.tss.monoexponential( ..., tss.fraction = 0.9, output = c("population", "popind", "individual", "single"), check = TRUE, verbose = FALSE)Arguments
... | |
tss.fraction | The fraction of steady-state required for callingsteady-state |
output | Which types of outputs should be produced? |
check | |
verbose | Describe models as they are run, show convergence of the model(passed to the nlme function), and additional details while running. |
Value
A scalar float for the first time when steady-state is achieved orNA if it is not observed.
References
Maganti, L., Panebianco, D.L. & Maes, A.L. Evaluation of Methods forEstimating Time to Steady State with Examples from Phase 1 Studies. AAPS J10, 141–147 (2008). https://doi.org/10.1208/s12248-008-9014-y
See Also
Other Time to steady-state calculations:pk.tss(),pk.tss.stepwise.linear()
A helper function to estimate individual and single outputs formonoexponential time to steady-state.
Description
This function is not intended to be called directly. Please usepk.tss.monoexponential.
Usage
pk.tss.monoexponential.individual( data, output = c("individual", "single"), verbose = FALSE)Arguments
data | a data frame as prepared by |
output | a character vector requesting the output types. |
verbose | Show verbose output. |
Details
If no model converges, then thetss.monoexponential.single and/ortss.monoexponential.individual column will be set to NA.
Value
A data frame with either one row (ifpopulation output isprovided) or one row per subject (ifpopind is provided). The columnswill be namedtss.monoexponential.population and/ortss.monoexponential.popind.
A helper function to estimate population and popind outputs formonoexponential time to steady-state.
Description
This function is not intended to be called directly. Please usepk.tss.monoexponential.
Usage
pk.tss.monoexponential.population( data, output = c("population", "popind"), verbose = FALSE)Arguments
data | a data frame as prepared by |
output | a character vector requesting the output types. |
verbose | Show verbose output. |
Details
If no model converges, then thetss.monoexponential.population column willbe set to NA. If the best model does not include a random effect for subjecton Tss then thetss.monoexponential.popind column of the output will be setto NA.
Value
A data frame with either one row (ifpopulation output isprovided) or one row per subject (ifpopind is provided). The columnswill be namedtss.monoexponential.population and/ortss.monoexponential.popind.
Compute the time to steady state using stepwise test of linear trend
Description
A linear slope is fit through the data to find when it becomesnon-significant. Note that this is less preferred than thepk.tss.monoexponential due to the fact that with more time or more subjectsthe performance of the test changes (see reference).
Usage
pk.tss.stepwise.linear( ..., min.points = 3, level = 0.95, verbose = FALSE, check = TRUE)Arguments
... | |
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 |
Details
The model is fit with a different magnitude by treatment (as a factor, ifgiven) and a random slope by subject (if given). A minimum ofmin.pointsis required to fit the model.
Value
A scalar float for the first time when steady-state is achieved orNA if it is not observed.
References
Maganti L, Panebianco DL, Maes AL. Evaluation of Methods forEstimating Time to Steady State with Examples from Phase 1 Studies. AAPSJournal 10(1):141-7. doi:10.1208/s12248-008-9014-y
See Also
Other Time to steady-state calculations:pk.tss(),pk.tss.monoexponential()
Convert the grouping info and list of results for each group into a resultsdata.frame
Description
Convert the grouping info and list of results for each group into a resultsdata.frame
Usage
pk_nca_result_to_df(group_info, result)Arguments
group_info | A data.frame of grouping columns |
result | A list of data.frames with the results from NCA parametercalculations |
Value
A data.frame with group_info and result combined, warnings filteredout, and results unnested.
Find NCA parameters with a given unit type
Description
Find NCA parameters with a given unit type
Usage
pknca_find_units_param(unit_type)Arguments
unit_type | The type of unit as assigned with |
Value
A character vector of parameters with a given unit type
Perform unit conversion (if possible) on PKNCA results
Description
Perform unit conversion (if possible) on PKNCA results
Usage
pknca_unit_conversion(result, units, allow_partial_missing_units = FALSE)Arguments
result | The results data.frame |
units | The unit conversion table |
allow_partial_missing_units | Should missing units be allowed for somebut not all parameters? |
Value
The result table with units converted
Add parentheses to a unit value, if needed
Description
Add parentheses to a unit value, if needed
Usage
pknca_units_add_paren(unit)Arguments
unit | The text of the unit |
Value
The unit with parentheses around it, if needed
Create a unit assignment and conversion table
Description
This data.frame is typically used for theunits argument forPKNCAdata().If a unit is not given, then all of the units derived from that unit will beNA.
Usage
pknca_units_table( concu, doseu, amountu, timeu, concu_pref = NULL, doseu_pref = NULL, amountu_pref = NULL, timeu_pref = NULL, conversions = data.frame())Arguments
concu,doseu,amountu,timeu | Units for concentration, dose, amount, andtime in the source data |
concu_pref,doseu_pref,amountu_pref,timeu_pref | Preferred units forreporting; |
conversions | An optional data.frame with columns of c("PPORRESU","PPSTRESU", "conversion_factor") for the original calculation units, thestandardized units, and a conversion factor to multiply the initial valueby to get a standardized value. This argument overrides any preferred unitconversions from |
Value
A unit conversion table with columns for "PPTESTCD" and "PPORRESU"ifconversions is not given, and adding "PPSTRESU" and"conversion_factor" ifconversions is given.
See Also
Theunits argument forPKNCAdata()
Examples
pknca_units_table() # only parameters that are unitlesspknca_units_table( concu="ng/mL", doseu="mg/kg", amountu="mg", timeu="hr")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")Print and/or summarize a PKNCAconc or PKNCAdose object.
Description
Print and/or summarize a PKNCAconc or PKNCAdose object.
Usage
## 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, ...)Arguments
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
Description
Print a PKNCAdata object
Usage
## S3 method for class 'PKNCAdata'print(x, ...)Arguments
x | The object to print |
... | Arguments passed on to |
Print the summary of a provenance object
Description
Print the summary of a provenance object
Usage
## S3 method for class 'provenance'print(x, ...)Arguments
x | The object to be printed |
... | Ignored |
Value
invisible text of the printed information
Print the results summary
Description
Print the results summary
Usage
## S3 method for class 'summary_PKNCAresults'print(x, ...)Arguments
x | A summary_PKNCAresults object |
... | passed to print.data.frame ( |
Value
x invisibly
See Also
Objects exported from other packages
Description
These objects are imported from other packages. Follow the linksbelow to see their documentation.
Round a value to a defined number of digits printing out trailing zeros, ifapplicable.
Description
Round a value to a defined number of digits printing out trailing zeros, ifapplicable.
Usage
roundString(x, digits = 0, sci_range = Inf, sci_sep = "e", si_range)Arguments
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- orhuman-readable output). |
si_range | Deprecated, please use |
Details
Values that are not standard numbers likeInf,NA, andNaN are returned as"Inf","NA", andNaN.
Value
A string with the value
See Also
During the summarization of PKNCAresults, do the rounding of valuesbased on the instructions given.
Description
During the summarization of PKNCAresults, do the rounding of valuesbased on the instructions given.
Usage
roundingSummarize(x, name)Arguments
x | The values to summarize |
name | The NCA parameter name (matching a parameter name in |
Value
A string of the rounded value
Add an attribute to an object where the attribute is added as a nameto the names of the object.
Description
Add an attribute to an object where the attribute is added as a nameto the names of the object.
Usage
setAttributeColumn( object, attr_name, col_or_value, col_name, default_value, stop_if_default, warn_if_default, message_if_default)Arguments
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 notexist (the column is filled with |
stop_if_default,warn_if_default,message_if_default | A character stringto provide as an error, a warning, or a message to the user if the |
Value
The object with the attribute column added to the data.
See Also
Set the duration of dosing or measurement
Description
Set the duration of dosing or measurement
Usage
## S3 method for class 'PKNCAconc'setDuration(object, duration, ...)setDuration(object, ...)## S3 method for class 'PKNCAdose'setDuration(object, duration, rate, dose, ...)Arguments
object | An object to set a duration on |
duration | The value to set for the duration or the name of the columnin 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 |
Value
The object with duration set
Set the exclude parameter on an object
Description
This function adds the exclude column to an object. To change theexclude value, use theexclude() function.
Usage
setExcludeColumn(object, exclude = NULL, dataname = "data")Arguments
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 theexclude column to. |
Value
The object with an exclude column and attribute
Set the dosing route
Description
Set the dosing route
Usage
setRoute(object, ...)## S3 method for class 'PKNCAdose'setRoute(object, route, ...)Arguments
object | A PKNCAdose object |
... | Arguments passed to another setRoute function |
route | A character string indicating one of the following: the columnfrom the data which indicates the route of administration, a scalarindicating the route of administration for all subjects, or a vectorindicating the route of administration for each dose in the dataset. |
Value
The object with an updated route
Set Intervals
Description
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.
Usage
set_intervals(data, intervals)Arguments
data | PKNCAdata object |
intervals | Proposed intervals |
Value
The data object with the intervals set.
Round a value to a defined number of significant digits printing out trailingzeros, if applicable.
Description
Round a value to a defined number of significant digits printing out trailingzeros, if applicable.
Usage
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, ...)Arguments
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- orhuman-readable output). |
si_range | Deprecated, please use |
Details
Values that are not standard numbers likeInf,NA, andNaN are returned as"Inf","NA", andNaN.
Value
A string with the value
See Also
Sort the interval columns by dependencies.
Description
Columns are always to the right of columns that they depend on.
Usage
## S3 method for class 'interval.cols'sort()Calculate the weight for sparse AUC calculation with the linear-trapezoidalrule
Description
The weight is used as thew_i parameter inpk.calc.sparse_auc()
Usage
sparse_auc_weight_linear(sparse_pk)Arguments
sparse_pk | A sparse_pk object from |
Details
w_i = \frac{\delta_{time,i-1,i} + \delta_{time,i,i+1}}{2}
\delta_{time,i,i+1} = t_{i+1} - t_i
Where:
w_iis the weight at time i
\delta_{time,i-1,i}and\delta_{time,i,i+1}are the changes between time i-1 and i or i and i+1 (zero outside of the time range)
t_iis the time at time i
Value
A numeric vector of weights for sparse AUC calculations the samelength assparse_pk
See Also
Other Sparse Methods:as_sparse_pk(),pk.calc.sparse_auc(),sparse_mean()
Calculate the mean concentration at all time points for use in sparse NCAcalculations
Description
Choices for the method of calculation (the argumentsparse_mean_method)are:
Usage
sparse_mean( sparse_pk, sparse_mean_method = c("arithmetic mean, <=50% BLQ", "arithmetic mean"))Arguments
sparse_pk | A sparse_pk object from |
sparse_mean_method | The method used to calculate the sparse mean (seedetails) |
Details
- "arithmetic mean"
Arithmetic mean (ignoring number of BLQ samples)
- "arithmetic mean, <=50% BLQ"
If >= 50% of the measurements are BLQ, zero. Otherwise, the arithmetic mean of all samples (including the BLQ as zero).
Value
A vector the same length assparse_pk with the mean concentrationat each of those times.
See Also
Other Sparse Methods:as_sparse_pk(),pk.calc.sparse_auc(),sparse_auc_weight_linear()
Set or get a sparse_pk object attribute
Description
Set or get a sparse_pk object attribute
Usage
sparse_pk_attribute(sparse_pk, ...)Arguments
sparse_pk | A sparse_pk object from |
... | Either a character string (to get that value) or a named vectorthe same length as |
Value
Either the attribute value or an updatedsparse_pk object
Extract the mean concentration-time profile as a data.frame
Description
Extract the mean concentration-time profile as a data.frame
Usage
sparse_to_dense_pk(sparse_pk)Arguments
sparse_pk | A sparse_pk object from |
Value
A data.frame with names of "conc" and "time"
Summarize a PKNCAdata object showing important details about theconcentration, dosing, and interval information.
Description
Summarize a PKNCAdata object showing important details about theconcentration, dosing, and interval information.
Usage
## S3 method for class 'PKNCAdata'summary(object, ...)Arguments
object | The PKNCAdata object to summarize. |
... | arguments passed on to |
Summarize PKNCA results
Description
Summarize PKNCA results
Usage
## S3 method for class 'PKNCAresults'summary( object, ..., drop_group = object$data$conc$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)Arguments
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 wasnot requested for a parameter within an interval. |
not_calculated | A character string to use when a parameter summary wasrequested, 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) beused? |
Details
Excluded results will not be included in the summary.
Value
A data frame of NCA parameter results summarized according to thesummarization settings.
See Also
PKNCA.set.summary(),print.summary_PKNCAresults()
Examples
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 summarysummary(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")Compute noncompartmental superposition for repeated dosing
Description
Compute noncompartmental superposition for repeated dosing
Usage
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, ...)Arguments
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 proportionalitywill be used from the input to output if they are not equal. The length ofdose.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) forextrapolation |
clast.pred | To use predicted as opposed to observed Clast, either givethe value for clast.pred here or set it to true (for automatic calculationfrom the half-life). |
tlast | The time of last observed concentration above the limit ofquantification. This is calculated if not provided. |
additional.times | Times to include in the final outputs in addition tothe standard times (see details). All |
check.blq | Must the first concentration measurement be below the limitof 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 beenachieved (between 0 and 1, exclusive). |
Details
The returned superposition times will include all of the followingtimes: 0 (zero),dose.times,time modulo tau (shiftingtime for eachdose time as well),additional.times, andtau.
Value
A data frame with columns named "conc" and "time".
See Also
Times relative to an event (typically dosing)
Description
Times relative to an event (typically dosing)
Usage
time_calc(time_event, time_obs, units = NULL)Arguments
time_event | A vector of times for events |
time_obs | A vector of times for observations |
units | Passed to |
Value
A data.frame with columns for:
- event_number_before
The index of
time_eventthat is the last one beforetime_obsorNAif none are before.- event_number_after
The index of
time_eventthat is the first one aftertime_obsorNAif none are after.- time_before
The minimum time that the current
time_obsis before atime_event, 0 if at least onetime_obs == time_event.- time_after
The minimum time that the current
time_obsis after atime_event, 0 if at least onetime_obs == time_event.- time_after_first
The time after the first event (may be negative or positive).
time_after andtime_before are calculated if they are at the same time asa dose, they equal zero, and otherwise, they are calculated relative to thedose number in theevent_number_* columns.
A helper function to generate the formula and starting values for theparameters in monoexponential models.
Description
A helper function to generate the formula and starting values for theparameters in monoexponential models.
Usage
tss.monoexponential.generate.formula(data)Arguments
data | The data used for the model |
Value
a list with elements for each of the variables
Calculate the variance for the AUC of sparsely sampled PK
Description
Equation 7.vii in Nedelman and Jia, 1998 is used for this calculation:
Usage
var_sparse_auc(sparse_pk)Arguments
sparse_pk | A sparse_pk object from |
Details
var\left(\hat{AUC}\right) = \sum\limits_{i=0}^m\left(\frac{w_i^2 s_i^2}{r_i}\right) + 2\sum\limits_{i<j}\left(\frac{w_i w_j r_{ij} s_{ij}}{r_i r_j}\right)
The degrees of freedom are calculated as described in equation 6 of the samepaper.
References
Nedelman JR, Jia X. An extension of Satterthwaite’s approximation applied topharmacokinetics. Journal of Biopharmaceutical Statistics. 1998;8(2):317-328.doi:10.1080/10543409808835241