
Methods for delays with an exponentially tilted primary
Source:R/pcens_cdf_exptilt.R
pcens_cdf_exptilt.RdAnalytical primary event censored CDFs for exponential, gamma and normal
delay distributions with an exponentially tilted primary event window, the
dexpgrowth() primary distribution with r equal to the tilt \(\rho\).
They honour use_numeric, and use the numerical method of
pcens_cdf.default() when no closed form applies.
Arguments
- object
A
primarycensoredobject as created bynew_pcens().- q
Vector of quantiles
- pwindow
Primary event window. Use
pwindow = 0for an exactly observed primary event, in which case the delay CDF is used directly.- use_numeric
Logical, if TRUE forces use of numeric integration even for distributions with analytical solutions. This is primarily useful for testing purposes or for settings where the analytical solution breaks down.
Details
With window width \(w\), delay CDF \(F\) and
\(J(x) = \int e^{-\rho u} f(u) du\) up to \(x\), the CDF at \(q\) is
$$
F_\rho(q) = F(q - w) + \frac{e^{\rho q} \{J(q) - J(q - w)\} -
\{F(q) - F(q - w)\}}{e^{\rho w} - 1}.
$$
Every term depends on one endpoint, \(q\) or \(q - w\), so each
endpoint is evaluated once and shared between neighbouring q.
Terms are on the log scale, and each difference is taken between the lower
or the upper tail terms, whichever loses less precision.
The exponential and gamma forms need \(\lambda + \rho > 0\) for rate \(\lambda\), so that the tilted delay distribution exists. Otherwise the numerical method is used. The numerical method is less accurate in the lower tail of a gamma with shape below 1, with a relative error of about 1e-5 in R and 1e-4 in Stan.
The direct form cancels as \(\rho \to 0\). With \(G_k(t) = \int (t - u)^k f(u) du\) up to \(t\), two series in \(\rho\) truncated after the second order replace it.
For \(|\rho| w\) below \(10^{-2}\), or \(10^{-3}\) for delays on the reals, and \(|\rho| (|q| + w) < 0.1\), the uniform window limit with its corrections, \(\{G_1(q) - G_1(q - w)\} / w + \rho \{G_2(q) - w G_1(q) - G_2(q - w) - w G_1(q - w)\} / (2 w) + \rho^2 \{G_3(q) - G_3(q - w) - 3 w [G_2(q) + G_2(q - w)] / 2 + w^2 [G_1(q) - G_1(q - w)] / 2\} / (6 w)\). Its relative error is below \((|\rho| w)^3 / 160\).
Otherwise, for delays on the non-negative reals with \(q < w\) and \(|\rho| q < 5 \times 10^{-3}\), \(\rho \{G_1(q) + \rho G_2(q) / 2 + \rho^2 G_3(q) / 6\} / (e^{\rho w} - 1)\). Its relative error is below \((|\rho| q)^3 / 24\).
Both errors are below \(10^{-8}\) at these limits.
The CDF agrees with numerical integration to a relative 1e-6 in the package tests.
See also
Low level primary event censored distribution objects and methods
new_pcens(),
pcens_cdf(),
pcens_cdf.default(),
pcens_cdf.pcens_pdiscretehazard(),
pcens_cdf.pcens_pdiscretestep(),
pcens_cdf.pcens_pgamma_dunif(),
pcens_cdf.pcens_pgengamma.orig_dunif(),
pcens_cdf.pcens_pgengamma_dunif(),
pcens_cdf.pcens_plnorm_dunif(),
pcens_cdf.pcens_pweibull_dunif(),
pcens_pmf(),
pcens_pmf.default(),
pcens_quantile(),
pcens_quantile.default(),
update.pcens()
Examples
# Exponential delay with a growing primary event process
pexp_obj <- new_pcens(
pdist = pexp, dprimary = dexpgrowth,
primary_args = list(r = 0.3), rate = 0.5
)
pcens_cdf(pexp_obj, q = c(1, 4, 8), pwindow = 2)
#> [1] 0.08649693 0.75597288 0.96697452
# Gamma delay with a declining process
pgamma_obj <- new_pcens(
pdist = pgamma, dprimary = dexpgrowth,
primary_args = list(r = -0.3), shape = 2, rate = 1
)
pcens_cdf(pgamma_obj, q = c(1, 4, 8), pwindow = 2)
#> [1] 0.06357351 0.79940359 0.99243183
# Normal delay, for example a difference of event times
pnorm_obj <- new_pcens(
pdist = pnorm, dprimary = dexpgrowth,
primary_args = list(r = 0.1), mean = 3, sd = 2
)
pcens_cdf(pnorm_obj, q = c(-1, 3, 8), pwindow = 2)
#> [1] 0.007780575 0.309880218 0.971725556