
Default method for computing primary event censored quantiles
Source:R/pcens_quantile.R
pcens_quantile.default.RdThis method inverts the primary event censored CDF by root-finding via
stats::uniroot() with extendInt = "upX". The censored CDF is monotone
in q, so stats::uniroot() extends its starting bracket outward as
needed and handles infinite L or D without special casing.
Usage
# Default S3 method
pcens_quantile(
object,
p,
pwindow,
L = -Inf,
D = Inf,
use_numeric = FALSE,
init = 5,
tol = 1e-08,
max_iter = 10000,
...
)Arguments
- object
A
primarycensoredobject as created bynew_pcens().- p
A vector of probabilities at which to compute the quantiles.
- pwindow
Primary event window
- L
Minimum delay (lower truncation point). Defaults to
-Inf, meaning no left truncation. For any finite value of L the distribution is left-truncated at L.- D
Maximum delay (upper truncation point). If finite, the distribution is truncated at D. If set to Inf, no upper truncation is applied. Defaults to Inf.
- use_numeric
Logical; if TRUE forces the use of numeric inversion even if an analytical solution is available (not yet implemented).
- init
Half-width of the initial search interval used when one or both truncation bounds are infinite. The starting interval is taken as
[-init, init](or[L, L + 2 * init]/[D - 2 * init, D]when only one bound is finite) and then extended outward bystats::uniroot()as needed. Defaults to 5, which brackets the bulk of most commonly used delay distributions.- tol
Numeric tolerance passed to
stats::uniroot().- max_iter
Maximum number of
stats::uniroot()iterations.- ...
Additional arguments passed to underlying functions.
See also
Low level primary event censored distribution objects and methods
new_pcens(),
pcens_cdf(),
pcens_cdf.default(),
pcens_cdf.pcens_pgamma_dunif(),
pcens_cdf.pcens_plnorm_dunif(),
pcens_cdf.pcens_pweibull_dunif(),
pcens_quantile()
Examples
# Create a primarycensored object with gamma delay and uniform primary
pcens_obj <- new_pcens(
pdist = pgamma,
dprimary = dunif,
dprimary_args = list(min = 0, max = 1),
shape = 3,
scale = 2
)
# Compute quantile for a single probability
pcens_quantile(pcens_obj, p = 0.8, pwindow = 1)
#> [1] 9.069147
# Compute quantiles for multiple probabilities
pcens_quantile(pcens_obj, p = c(0.25, 0.5, 0.75), pwindow = 1)
#> [1] 3.951257 5.853359 8.351001
# Compute quantiles for multiple probabilities with truncation
pcens_quantile(pcens_obj, p = c(0.25, 0.5, 0.75), pwindow = 1, D = 10)
#> [1] 3.666380 5.270768 7.092986
# Compute quantiles with left truncation
pcens_quantile(pcens_obj, p = c(0.25, 0.5, 0.75), pwindow = 1, L = 1, D = 10)
#> [1] 3.689124 5.285634 7.102640