| Title: | Integration-Based Coefficients of Variation |
|---|---|
| Description: | Estimate coefficient of variation percent (CV%) for any arbitrary distribution, including some built-in estimates for commonly-used transformations in pharmacometrics. Methods are described in various sources, but applied here as summarized in: Prybylski, (2024) <doi:10.1007/s40262-023-01343-2>. |
| Authors: | John Prybylski [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-5802-0539>) |
| Maintainer: | John Prybylski <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.2 |
| Built: | 2026-05-23 06:20:07 UTC |
| Source: | https://github.com/jprybylski/pmxcv |
Built-in integration-based %CV functions
dist.intcv( dist = "log", ..., exact = ifelse(dist == "log", TRUE, FALSE), lambda = NULL, fun = FALSE )dist.intcv( dist = "log", ..., exact = ifelse(dist == "log", TRUE, FALSE), lambda = NULL, fun = FALSE )
dist |
Selection of built-in distributions. |
... |
passed to moment() |
exact |
If there is an exact moment generating function, use that. Default TRUE only for log |
lambda |
shape parameter for nonmemboxcox() |
fun |
return function (for use in invcv()) |
Percent CV
dist.intcv("log", v = 0.2) dist.intcv("logit", u = 0.5, v = 0.3)dist.intcv("log", v = 0.2) dist.intcv("logit", u = 0.5, v = 0.3)
Built-in moment functions
dist.moment( dist = "log", ..., exact = ifelse(dist == "log", TRUE, FALSE), lambda = NULL )dist.moment( dist = "log", ..., exact = ifelse(dist == "log", TRUE, FALSE), lambda = NULL )
dist |
Selection of built-in distributions. |
... |
passed to moment() |
exact |
If there is an exact moment generating function, use that. Default TRUE only for log |
lambda |
shape parameter for nonmemboxcox() |
moment
dist.moment("log", u = 2, v = 0.2, n = 2) dist.moment("logit", u = 0.5, v = 0.2, n = 1)dist.moment("log", u = 2, v = 0.2, n = 2) dist.moment("logit", u = 0.5, v = 0.2, n = 1)
Integration-based CV%
intcv(...)intcv(...)
... |
Arguments passed to moment() |
Percent CV
intcv(u = 1, v = 0.2, pdist = exp, qdist = log)intcv(u = 1, v = 0.2, pdist = exp, qdist = log)
Variance from CV%
invcv(cvfun, cv, verbose = FALSE, ...)invcv(cvfun, cv, verbose = FALSE, ...)
cvfun |
intcv()-based function |
cv |
CV% generated from cvfun |
verbose |
extra output |
... |
Other parameters to pass to cvfun |
Best-fit variance
logcv <- dist.intcv("log", fun = TRUE) invcv(logcv, cv = 30)logcv <- dist.intcv("log", fun = TRUE) invcv(logcv, cv = 30)
Moment function
moment(...)moment(...)
... |
all arguments passed to moment_f() |
moment
moment(n = 3, u = 1, v = 0.2, pdist = exp, qdist = log)moment(n = 3, u = 1, v = 0.2, pdist = exp, qdist = log)
Integratable moment function
moment_f(x, u, v, n, pdist, qdist)moment_f(x, u, v, n, pdist, qdist)
x |
numeric vector |
u |
mean |
v |
variance |
n |
moment number |
pdist |
un-transform function for transformed random variable (eg, exp()) |
qdist |
transform function (eg, log()) |
Point result of the moment function
moment_f(0, u = 1, v = 0.2, n = 1, pdist = exp, qdist = log)moment_f(0, u = 1, v = 0.2, n = 1, pdist = exp, qdist = log)
Parameters are typically treated as lognormally-distributed by NONMEM users. Box-Cox transforms are typically applied to the exponentiated individual ETA parameters; this means the parameter is neither Box-Cox distributed nor lognormally-distributed, but both. To get the "Box-Cox Transform" as it would be relevant for CV% calculation, these properties have to be considered.
nonmemboxcox(x, lambda, theta = 1, inv = FALSE)nonmemboxcox(x, lambda, theta = 1, inv = FALSE)
x |
random vector. Must be positive. |
lambda |
shape parameter |
theta |
centrality parameter |
inv |
inverse transform |
Box-Cox transformed or untransformed vector
y <- nonmemboxcox(1.5, lambda = 0.5, theta = 1) nonmemboxcox(y, lambda = 0.5, theta = 1, inv = TRUE)y <- nonmemboxcox(1.5, lambda = 0.5, theta = 1) nonmemboxcox(y, lambda = 0.5, theta = 1, inv = TRUE)
Numeric CV% of a sample
numcv(x, ...)numcv(x, ...)
x |
numeric vector |
... |
other arguments for sd() and mean() |
Percent cv
test_x <- rnorm(1000, mean=50, sd=5) cv <- numcv(test_x) cv # expect ~ 10(%)test_x <- rnorm(1000, mean=50, sd=5) cv <- numcv(test_x) cv # expect ~ 10(%)