Skip to contents

Computes patient-level state occupancy probabilities from a supported Markov transition model. Frequentist first-order models use the optimized native engine; other supported workflows use the reference engine.

Usage

soprob_markov(
  model,
  newdata,
  times = NULL,
  y_levels,
  absorb = NULL,
  time_var = "time",
  p_var = "yprev",
  p2_var = NULL,
  gap_var = NULL,
  time_covariates = NULL,
  include_re = FALSE,
  id_var = NULL,
  n_draws = 100L,
  seed = NULL,
  ...
)

Arguments

model

A Markov transition model fitted by vglm_markov(), orm_markov(), or blrm_markov(). The robust robcov_vglm result returned by vglm_markov() is supported; raw backend fits without fitting- wrapper provenance are not.

newdata

A data frame containing one baseline prediction row per patient or profile.

times

Required consecutive visits, in increasing order. The recursion takes one transition per value, so leaving out visits does not skip time; see sops(). Unlike sops(), this function does not warn when times leaves out fitted visits.

y_levels

Ordered outcome-state levels. The number of levels must equal the fitted threshold count plus one.

absorb

Optional absorbing state levels.

time_var

Name of the model time variable.

p_var

Name of the previous-state variable.

p2_var

Optional second previous-state variable. A non-NULL value selects second-order recursion.

gap_var

Optional elapsed-time-gap variable.

time_covariates

Optional data frame with one row per requested visit containing precomputed time-varying covariates.

include_re

For blrm fits, include fitted random-effect draws for known IDs.

id_var

ID column used for blrm random effects.

n_draws

Number of blrm posterior draws, or NULL for all draws.

seed

Optional seed used when selecting posterior draws.

...

Reserved for internal posterior draw batching.

Value

An array of state probabilities. Frequentist fits return [patient, time, state]; Bayesian fits return [draw, patient, time, state].