Survival outcomes
Restricted Cox methods for right-censored outcomes.
fit_cox(durations, events, exposures, covariates=None, *, q=4, breaks=None, alpha=0.05, weights=None, offset=None, cluster_ids=None)
Fit a right-censored Cox model and sum exposure coefficients.
Durations must be positive, events must be zero or one, and
inputs must be complete numeric arrays. Positive case weights enter the
risk sets and event contributions. As in R's coxph default, fractional
weights trigger a robust score-sandwich variance; integer weights use
model-based variance. A finite offset gives one known log-hazard
contribution per row. Exact integer cluster_ids group row scores for
robust uncertainty; they do not change the fitted coefficients or exposure
cuts. This subset has no formula. Shared event
times use Efron's approximation. Its hazard ratio is conditional, not a
marginal risk or survival contrast.
fit_cox_formula(formula, data, exposures, *, q=4, breaks=None, alpha=0.05, weights=None, cluster_ids=None, offset=None)
Fit a complete-data additive survival formula.
Write Surv(time,event) ~ exposure + C(adjustment). The two response
columns must hold positive follow-up times and zero-one event indicators.
Exposure terms must be plain numeric columns. C(name) is allowed for
a text adjustment column, with the first sorted level as reference.
weights, cluster_ids and known log-hazard offset are row
vectors in the same order as data. Missing rows are not removed.
fit_cox_bootstrap(durations, events, exposures, covariates=None, *, q=4, breaks=None, alpha=0.05, degree=1, B=200, MCsize=None, seed=None)
Fit a marginal Cox curve with Monte Carlo events and row-bootstrap SE.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Notes
Event times are drawn by inverting the fitted cumulative hazard and are censored at the last observed follow-up time. R qgcomp 2.19.6 instead compares each hazard increment directly with a uniform draw and can produce missing times at its last support point. This intentional difference is recorded in the validation report. Independent censoring, proportional hazards, and causal identification require substantive assessment.
qgcomp_survcurve_boot(result)
Return marginal and conditional survival curves without uncertainty bands.
mdfq is the marginal model curve at each fitted joint intervention
level. mdfpop averages those curves equally across levels. cdfpop
averages conditional-model curves over all original adjustment profiles
and levels. Following R's helper, cdfq holds each level's conditional
curve for the first original adjustment profile, not its population
average. The four tables may have different time grids: the marginal
grid comes from simulated outcomes and the conditional grid from observed
outcomes. No confidence bands are supplied.
For a prequantized fit, Python uses the actual pooled-quartile intervention levels saved by the bootstrap fit. R qgcomp 2.19.6 instead reconstructs zero-based integer levels from its saved breaks when q is NULL; the two displays can differ in that setting.