pcens_quantile.default: Default method for computing primary event censored quantiles

View source: R/pcens_quantile.R

pcens_quantile.defaultR Documentation

Default method for computing primary event censored quantiles

Description

This 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 primarycensored object as created by new_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 by stats::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.

Value

A numeric vector containing the computed primary event censored quantiles.

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)

# Compute quantiles for multiple probabilities
pcens_quantile(pcens_obj, p = c(0.25, 0.5, 0.75), pwindow = 1)

# Compute quantiles for multiple probabilities with truncation
pcens_quantile(pcens_obj, p = c(0.25, 0.5, 0.75), pwindow = 1, D = 10)

# Compute quantiles with left truncation
pcens_quantile(pcens_obj, p = c(0.25, 0.5, 0.75), pwindow = 1, L = 1, D = 10)

primarycensored documentation built on June 15, 2026, 5:06 p.m.