mostr (development version)
Breaking changes
sim_markov()replacessim_trajectories_markov(),sim_actt1_markov(), andsim_actt2_markov(). Choose a model withpreset:"actt1","actt2","violet", orNULLto supply your ownbaseline_data,intercepts, andlp_function.presethas no default. Any model argument you supply, such asinterceptsorbaseline_data, replaces that part of the preset and keeps the rest. Each preset’s model is described in its own help topic:?actt1_preset,?actt2_preset, and?violet_preset.sim_markov("actt2", ...)gives the same trajectories assim_actt2_markov(...)did with the same arguments and seed.sim_markov()simulates exactly the patients in a suppliedbaseline_dataand stops if you also supplyn_patientsortreatment_prob, which only sample patients from a preset. Previously the trial wrappers recycled the columns of a suppliedbaseline_dataovern_patientsgenerated patients, so a 2-patientbaseline_datawith the defaultn_patients = 1000gave 1,000 patients.preset = "actt1"uses the ACTT-2 transition model with the starting states reported for ACTT-1 (13.1%, 41.4%, 18.4%, and 27.1% in states 4 to 7) and a threshold for death raised from -22.0693 to -21.4071, so that 18% of control patients have died by day 28. The ACTT-1 model based on Rohde et al. (2024) thatsim_actt1_markov()used has been removed, andvignette("partial-po-vglm-sops")now simulates VIOLET data.An
lp_functionnow receivestreatment_effect, the treatment effect on the current day aftertreatment_effect_decay, instead ofparameter, sotreatment_effect_decayalso works for your own models. Withpreset = NULL,treatment_effectdefaults to 0,extra_paramstoNULL,absorbing_statesto the worst state (length(intercepts) + 1),covariate_namesto every column ofbaseline_dataexceptidandyprev, andfollow_up_timeto 28 days (previously 60).lp_violet()has been removed.
New features
New
preset = "violet"simulates 4-state daily trajectories (home, in hospital, on a ventilator or with ARDS, dead) from the Markov model that Frank Harrell fitted to the VIOLET trial of vitamin D3 to create his simulated trialsimlongord. Patients are sampled from the 1,351 VIOLET patients’ starting states, ages, and SOFA scores. The default treatment odds ratio is 0.75, as insimlongord, and the daily state proportions agree withsimlongordwithin simulation error.violet_baselinenow holds the 1,351 VIOLET patients as 858 distinct combinations of starting state, age, and SOFA score with their countsn(previously 250,000 resampled patients in a modified 6-state coding). Its states followsim_markov("violet").
Minor improvements
sops(),avg_sops(),avg_time(), andavg_comparisons()now warn whentimesskips fitted visits. SOPs are calculated one transition per value oftimes, so with daily visitstimes = c(1, 7, 14)gives the probabilities after 1, 2, and 3 transitions, labelled 1, 7, and 14, not the probabilities on days 7 and 14. To get SOPs at selected visits, request every visit, such astimes = 1:14, and keep the rows you need. The functions also warn whentimesis not in increasing order, and, for the starting profiles stored on a model fitted byorm_markov(),blrm_markov(), orvglm_markov(), whentimesdoes not begin at the first follow-up visit. There is no warning whengap_varis supplied, because each transition then uses its own elapsed time, or for times after the last fitted visit. The help fortimesnow explains that it lists consecutive visits.sim_markov("actt1")andsim_markov("actt2")are much faster for large samples, because they now calculate each day’s linear predictor for all patients in one step instead of one patient at a time, assim_markov("violet")already did. The trajectories for a given seed are unchanged. A model that you supply throughlp_functionis still called once per patient.
Bug fixes
- Wald intervals from simulation or bootstrap draws (
conf_type = "wald"ininferences()) are now centered on the point estimate for SOP and time-in-state comparisons fromavg_comparisons()and for SOPs frominterpolate_sops(). These intervals were previously centered on the mean of the draws, which differs from the point estimate, so the reported estimate was not at the middle of its interval. Standard errors and percentile intervals are unchanged.
mostr 0.1.1
-
sim_actt2_markov()uses a model refitted with states 1 and 2 merged, because state 2 was mostly recorded only at study visits. The old fit rehospitalized about 29% of control patients (2% observed); the new one about 2.7%. The defaulttreatment_effectofsim_actt2_markov()andsim_actt1_markov()is now -0.0730.
mostr 0.1.0
sim_actt1_markov()now adds the average age and sex contribution of an ACTT-1 patient (0.2253 on the log-odds scale) to every threshold. The reported thresholds describe a woman aged 0, so simulated patients previously moved to better states too quickly; placebo mortality by day 28 rises from 9.5% to 13.4%, closer to the reported 15.2% by day 29.Bootstrap refits (
inferences(method = "bootstrap")andmethod = "fwb") now always resample the data stored byorm_markov()orvglm_markov(): the rows used for fitting, after anysubset, with their fitting weights. Therefit_dataargument ofsops(),avg_sops(),avg_comparisons(),avg_time(),plot_transitions(),plot_correlation(), andplot_variogram()has been removed; drop it from existing calls.newdatastill sets the patient profiles used for prediction and can contain any profiles. Refit bootstraps of models fitted without these wrappers now error.bootstrap_model_coefs()no longer has adataargument. It resamples the patients stored on a model fitted withorm_markov()orvglm_markov(), andid_varnow defaults to the patient ID column given when fitting.fast_group_bootstrap(),materialize_bootstrap_sample(),apply_to_bootstrap(),bootstrap_analysis_wrapper(), andrelevel_factors_consecutive()are no longer exported. Useinferences()orbootstrap_model_coefs()for bootstrap calculations.Bootstrap refits use starting values (from
use_coefstart = TRUEor acoefstartpassed tovglm_markov()) only when the resampled data contain every outcome state. When a state is missing, the refitted model has fewer intercepts, so it is fitted without starting values. A refit with starting values that fails, for example because a covariate level is absent from the resample, is retried once without them.avg_sops()now acceptsvariables = NULLto average over patients using their observed starting states and covariates, with the existing analytical, posterior, simulation, and bootstrap inference methods.avg_time()estimates average total time in separate or pooled states, using visit sums or mapped elapsed-time integration. It supports conditional and unconditional analytical variance, posterior intervals, and all existing simulation and bootstrap methods. Usevcov()for analytical covariance andget_draws()for retained time-total draws.With
time_mapand notarget_times,avg_comparisons(estimand = "time_in_state")(and"time_benefit") andtime_in_state()for SOP data frames now integrate frombaseline_time(default0) to the last mapped visit, including the interval before the first visit. Previously, the omitted grid started at the first mapped visit. Setbaseline_time = NULLor supplytarget_timesto choose the period.avg_time()uses the same default.When
variablessets the starting state (for examplevariables = list(yprev = c("1", "2"))), real-time summaries fromavg_time(),avg_comparisons(estimand = "time_in_state"), andinterpolate_sops()now start each scenario in the set state atbaseline_time. Previously they started from the patients’ observed starting states. These results support only conditional variance:inferences(method = "delta")requiresvcov = "conditional"(or a coefficient covariance matrix), andmethod = "mvn"remains available; unconditional delta, score-bootstrap, bootstrap, and FWB inference now error.plot_time()plotsavg_time()results.type = "bar"draws one horizontal stacked bar per scenario, split into the average time in each state (“Grotta bars”);scale = "proportion"shows shares of follow-up.type = "pointrange"draws one point per state and scenario with its vertical confidence interval. Scenarios are drawn in black and successively lighter shades of gray.inferences()now testsavg_comparisons()results against “no effect” by default: 0 for differences and 1 for ratios. The result gainsstatistic,p.value, ands.valuecolumns. The new default isnull = "auto"; pass a number to test against another value, ornull = NULLto skip the test. SOP and average-time results are still not tested unless you supplynull.plot_correlation()andplot_variogram()now default to Spearman rank correlation for observed data and fitted models, accounting for tied states. Usemethod = "pearson"to retain the previous calculation.plot_correlation()now uses a 0-1 color scale when all available correlations are nonnegative, retaining -1 to 1 when negative correlations are present. Setfill_limitsexplicitly to keep a common scale across plots.Speed up row assembly, grouped summaries, patient bootstrap materialization, and baseline selection using data.table internally. Results remain data frames.
Initial release of Markov Ordinal State Transition modeling tools, migrated from markov.misc with its original authorship and GPL license preserved.
Retain Markov data generation, first- and second-order transition models, state occupancy probabilities, treatment comparisons, time in state, diagnostics, and analytical, posterior, MVN, and bootstrap inference.
Remove non-Markov generators, simulation-study and power workflows, Arrow sampling, endpoint conversions, competing-risk analyses, and coefficient tidiers. The simulation-truth helper
calc_time_in_state_diff()is also excluded; model-based summaries remain available throughtime_in_state().Use Markov-generated data throughout examples, tests, and all nine vignettes.
sim_actt2_markov()supports custom follow-up, including 60 days; the separate Brownian-calibrated 60-day generator is excluded.
