Change settings, then run. New sample changes the seed and runs again. Advanced holds the follow-up and model settings.
Causal structure (DAG)
Stage = cancer stage I-IV; survival = time to death. Solid arrows are active. Dotted paths are switched off.
Stage distribution by treatment
Percentages within each treatment group.
Key numbers · hazard ratio
The true effect is a known within-stage HR. The other rows are estimated from this sample.
Kaplan-Meier curves
Observed treatment groups
Stage-adjusted survival
Both treatments in the same stage distribution
Treatment effect estimates
A vs B · lower values favour A
Read the estimates
Hover over or tap a point, or open Read the estimates above.
Points: HR estimates. Lines: 95% confidence intervals. The dashed reference is HR = 1.
Interpretation
Median survival (years)
RESULTS
The same data. Two different comparisons.
The observed curves show the groups as assigned. The adjusted curves compare both treatments using the same stage mix. These are results from the last completed simulation.
Kaplan-Meier estimates with pointwise 95% log-log confidence intervals. Numbers at risk are taken directly from the simulated data.
Stage-standardised survival
Known model curves, when selected, are calculated from the generating hazards and the same pooled stage weights. They are not fitted to outcomes.
Survival probabilities and time alive
Survival differences are percentage points, A minus B. Restricted mean survival time (RMST) is the area under the curve up to the selected follow-up horizon. These are point estimates; HR intervals do not provide intervals for these differences.
Read the HRs alongside the curves
PATIENT DATA
Look behind the curves.
One row per fictional patient. Filter the rows, check what the columns mean and download the selection. These filters do not change the models or the dashboard.
The filtered download uses the three controls above, not the table's text search. CSV files retain full numeric precision.
Simulated cohort
Swipe or scroll the table sideways to see all columns. The text search only changes the displayed rows.
Variable definitions
Variable
Meaning
id
Fictional patient identifier.
treatment
Treatment A or Treatment B.
trt
Treatment coding used by the Cox models: A = 1, B = 0.
stage
Baseline cancer stage, I-IV. A categorical variable in the adjusted model.
time
Observed follow-up in years: the minimum of death, loss to follow-up and study end.
event
1 = observed death; 0 = right-censored.
followup_status
Why follow-up ended: death, loss to follow-up or study end.
probability_A
Known probability of receiving Treatment A in the allocation model.
INTERPRETATION
What does this run tell us?
Read the patient differences alongside the treatment estimates. The explanation follows the last completed run. Use the examples below to explore one change at a time.
Try one change at a time
These examples use the current sample size, seed and follow-up settings. Each button changes the named scenario settings, runs the analysis and returns to the simulation view.
More confounding sets observational allocation, advanced-stage preference and strength 0.90. Randomised allocation changes allocation only. No treatment effect changes the true HR to 1 only.
ADVANCED
The assumptions behind the example.
Adjust how patients, treatment and follow-up are generated. Apply and run uses all current settings. The starting values are enough for a first visit.
Model and follow-up
Bootstrap bands are pointwise 95% percentile intervals. Patients are resampled within stage; the original pooled stage weights are kept fixed. Even 300 resamples is an exploratory setting, not a full simulation study.
stage ~ categorical(p1, p2, p3, p4)
P(A | stage) = logistic(intercept + slope × (stage - 2.5))
hazard = baseline × stage_HR^(stage - 1) × treatment_HR^A
death time ~ exponential(hazard)
loss to follow-up ~ exponential(censoring rate)
observed time = min(death, loss to follow-up, study end)
The starting population has 25% in each stage. The allocation intercept gives an expected 50% share receiving A. The slope is 1.6 times the strength setting, with its sign set by the direction control.
Stage is a categorical adjustment variable, not a linear score in the fitted Cox model. There is no treatment-by-stage interaction; the generating HR is the same within each stage.
Censoring in this run
The loss-to-follow-up rate is calibrated to the expected total censoring proportion, including study end. Targets below the study-end minimum are not attainable. The observed proportion varies between samples.
Allocation and overlap
Analysis details
Cox models.
The crude model contains treatment only. The adjusted model contains treatment and categorical stage. Both use Efron's method for tied event times. HR intervals are 95% Wald intervals on the log-HR scale.
Survival curves.
For the adjusted curves, the model predicts survival under A and B at each stage. The predictions are averaged with the pooled stage proportions from the complete cohort. This is not survival for an 'average-stage' patient.
Time summaries.
The median is the first time the estimated survival curve reaches 50%. NR means that this threshold is not reached within supported follow-up. RMST uses exact step-function integration. Unsupported tail probabilities and RMST values are left blank rather than extrapolated.
Scope.
The model has a baseline treatment, one measured confounder, constant stage-specific hazards and independent loss to follow-up. It does not include competing events, delayed entry, treatment switching or time-varying covariates.
WHY THIS MATTERS
A treatment comparison is also a patient comparison.
A useful treatment can look less effective when it is given to patients with a poorer prognosis. Here, we can examine that problem because we choose the treatment effect before creating the patients.
Why start with a simulation?
With real study data, we do not know the effect we are trying to estimate. Here, we choose it before generating any patients. We can then see what happens when treatment allocation, sample size and follow-up change.
All patients, hazards and treatment effects in this app are fictional. The stage labels are used to explain a method, not to represent a particular cancer or clinical recommendation.
Where confounding enters
In the observational setting, stage influences both treatment allocation and the event hazard. The crude comparison therefore mixes treatment differences with differences in the patients receiving treatment.
Randomised allocation removes the stage-to-treatment link in the generating model. It does not force exact stage balance in a finite sample.
Background: Hernán and Robins [1].
Two survival questions
Observed:
How did the patients receiving A and B survive in this sample? The Kaplan-Meier curves answer this descriptive question.
Standardised:
What would the model predict for A and B if both were applied to the same pooled stage distribution? Predictions are made separately for each stage, then averaged using the same weights for both treatments.
Prediction and averaging: survival package documentation [3-4].
Why the HR is not the whole result
The hazard ratio compares instantaneous event hazards among patients still alive. It is not a ratio of survival probabilities or a percentage change in the chance of death over five years.
The known HR in this app is a within-stage model parameter. A crude Cox HR is a different summary and can differ even without confounding. This is why the app also reports survival probabilities and restricted mean survival time.
Interpretation of hazard ratios: Hernán [2]; non-collapsibility: Daniel and colleagues [5].
What adjustment needs
A causal interpretation needs more than an adjusted model: well-defined treatments, consistency, exchangeability after adjustment, treatment overlap, suitable censoring assumptions and a correctly specified analysis.
Stage is measured without error and is the only common cause of allocation and survival in this simulation. Real data may involve unmeasured confounding, measurement error, treatment switching, time-varying confounding or other complications not included here.
Causal assumptions: Hernán and Robins [1].
How to explore the example
Start with the default run and compare the stage distribution with the two survival plots. Increase the allocation imbalance, then try randomised allocation without changing the treatment effect.
Next, set the true HR to one. Finally, compare a smaller and a larger sample, and use New sample to see sampling variation. Adjustment need not move the estimate closer to the truth in every individual run.