Maps visit-scale SOP output from sops() or avg_sops() to a real elapsed
time scale and linearly interpolates probabilities within patient, state,
draw, treatment, and strata groups.
Arguments
- x
A
markov_sopsormarkov_avg_sopsobject.- time_map
A named numeric vector mapping visit labels to real times, or a data frame with visit and real-time columns. Data frames may use columns
visitandreal_time,visitandtime, or their first two columns.- target_times
Optional numeric real-time grid. If
NULL, uses the mapped visit times plusbaseline_timewhen the baseline anchor is enabled.- baseline_time
Real time of the observed baseline state. The default
0adds a fixed anchor from the stored previous-state values. Set toNULLto disable baseline anchoring.- normalize
Logical. If
TRUE, normalize interpolated estimates so state probabilities sum to one within each time and group.
Value
An interpolated data frame with the same core columns as x, where
time is on the real-time scale.
Details
The recommended workflow for irregular assessment schedules is:
Recode assessment days to visit indices, for example day 3, 7, 14, and 28 to visit
1:4.Fit the Markov model with the visit index as a factor.
Compute visit-scale SOPs with
sops()oravg_sops().Use
interpolate_sops()ortime_in_state(..., time_map = ...)for real-day summaries.
With RCT standardization from avg_sops(), the empirical baseline anchor is
shared across treatment counterfactual groups. When variables in
avg_sops() sets the previous-state variable (for example yprev), every
patient starts in the set state, so the anchor for that scenario gives
probability 1 to that state and 0 to the others.
If x contains stored simulation, bootstrap, or posterior draws, the draws
are interpolated too. Interval columns are then recomputed from the
interpolated draws. Coefficient-only draws treat the empirical baseline anchor
as fixed; empirical score-bootstrap, FWB, and refit-bootstrap draws use the
corresponding draw-specific patient weights or resampled cohort.
If interval columns are present but stored draws are unavailable,
interpolate_sops() warns and falls back to interpolating interval endpoints.
Each numeric series is interpolated only within its own finite source-time
support. Targets before its first or after its last available value return
NA; the function never extrapolates a series from another group's wider
support.
