Replaces the delay distribution parameters, and optionally the primary
event distribution arguments, of an existing pcens object.
The delay and primary distribution functions, the primary event CDF and
the class are kept as they are.
The updated object therefore dispatches to the same pcens_cdf() method
without looking up names or rebuilding the class.
This is cheaper than calling new_pcens() again when one distribution is
evaluated for many parameter sets, for example posterior draws.
Usage
# S3 method for class 'pcens'
update(object, ..., primary_args = NULL)Arguments
- object
A
pcensobject as created bynew_pcens().- ...
Named delay distribution parameters. Each one replaces the entry of the same name in
object$args, or is added if not present. Parameters that are not given keep their current values.- primary_args
Optional named list of primary event distribution arguments. These are merged into
object$primary_argsin the same way as...is merged intoobject$args. Defaults toNULL, which leaves the primary event distribution arguments unchanged.
Value
A pcens object with the same class as object and updated
args, primary_args and dprimary_args fields. See new_pcens() for
the fields of a pcens object.
Details
Parameters are merged rather than replaced as a whole, so
update(object, scale = 3) changes scale and keeps all other
parameters. Parameters cannot be removed; use new_pcens() for that.
A name in ... that is not already in object$args must be an argument
of object$pdist other than its first, unless pdist takes ....
Otherwise an error is raised. Names in primary_args are not checked
against dprimary.
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()
Examples
obj <- new_pcens(
pdist = pgamma, dprimary = dunif,
primary_args = list(min = 0, max = 1),
shape = 1, scale = 1
)
obj <- update(obj, shape = 2, scale = 3)
pcens_cdf(obj, q = c(1, 5, 10), pwindow = 1)
#> [1] 0.01571917 0.44166025 0.82397787
# Update the primary event distribution arguments
obj <- new_pcens(
pdist = pgamma, dprimary = dexpgrowth,
primary_args = list(r = 0.2),
shape = 2, scale = 3
)
obj <- update(obj, primary_args = list(r = 0.5))
pcens_pmf(obj, x = 0:5, pwindow = 1)
#> [1] 0.01385490 0.07361513 0.11112116 0.12144831 0.11699152 0.10530254
