View source: R/transition_probability.R
| compute_trans_prob | R Documentation |
Combines one clock-reset cumulative cause-specific hazard curve per allowed
edge using a regular-grid entry-mass/sojourn convolution. The result is not
a general Markov P(s,t) matrix: each row is conditional on fresh entry
into its named starting state at elapsed duration zero.
compute_trans_prob(
cum_hazards,
structure,
s = 0,
times = NULL,
start_state = NULL,
grid_step = NULL,
target_grid_points = 1024L,
max_grid_points = 131073L,
grid_tol = 5e-04,
max_grid_refinements = 7L,
check_grid = TRUE,
prob_tol = 1e-08,
extrapolate = c("error", "flat")
)
cum_hazards |
Named list of data frames, one for every allowed edge.
Names must be |
structure |
An |
s |
Legacy starting-time argument. Only zero is supported. |
times |
Finite nonnegative elapsed durations. If |
start_state |
State in which fresh entry occurs. The default is the
common initial state stored in |
grid_step |
Optional initial internal grid step. |
target_grid_points |
Initial number of regular-grid intervals when
|
max_grid_points |
Maximum number of internal grid points, including elapsed duration zero. |
grid_tol |
Maximum probability change allowed on grid refinement.
The default |
max_grid_refinements |
Maximum number of step halvings. |
check_grid |
Whether to require grid-refinement convergence. Keep
|
prob_tol |
Positive tolerance for probability bounds and unit mass. |
extrapolate |
Either |
Cumulative hazards are evaluated as right-continuous step functions. Within each regular interval, total exit probability is allocated to causes in proportion to their cumulative-hazard increments. Entry mass is assigned to the interval's right endpoint. Grid refinement controls these approximations. A positive cumulative hazard at duration zero is rejected because the data contract permits no instantaneous fresh-entry transition. Tiny monotonicity corrections within the declared tolerance are counted. Probabilities are never clipped or row-normalized.
A trans_prob object. entry_prob and its temporary
alias P are arrays ordered selected starting state by occupied
state by elapsed time; the starting-state dimension has length one.
state_occ is the selected starting-state slice. The
object also records time, structure, fresh-entry conditioning,
support and extrapolation policy, the final internal grid and step,
convergence error/refinements, roundoff corrections, and
prob_tol.
Curves must cover every declared edge and represent cumulative
cause-specific hazards on the clock-reset duration scale. The function does
not estimate hazards, accept left truncation or s > 0, condition on
an ongoing sojourn, support cyclic/recurrent graphs, or provide uncertainty.
Prediction beyond conservative support fails unless the explicit flat-hazard
sensitivity extension is selected.
ms <- define_multistate(c("A", "B"), "B", list(A = "B"))
tt <- seq(0, 2, length.out = 2001)
hazards <- list("A->B" = data.frame(time = tt, hazard = 0.4 * tt))
pr <- compute_trans_prob(hazards, ms, times = c(0, 1, 2),
target_grid_points = 512)
pr$state_occ
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.