Skip to content

Add show/coeftable/confint to models; KaplanMeier show (closes #78, #79)#84

Merged
lrnv merged 1 commit into
JuliaSurv:mainfrom
andreasnoack:model-show-methods
Jul 15, 2026
Merged

Add show/coeftable/confint to models; KaplanMeier show (closes #78, #79)#84
lrnv merged 1 commit into
JuliaSurv:mainfrom
andreasnoack:model-show-methods

Conversation

@andreasnoack

Copy link
Copy Markdown
Contributor

Summary

Gives every model class a terse, faithful show plus an explicit coeftable/confint inference layer, and removes the non-idiomatic summary(::Cox). Closes #78 and #79.

The design follows the S/R print-vs-summary convention: show renders only stored state (coefficients, baseline, fit statistics) and never computes covariance-derived quantities; inference is requested explicitly via coeftable/confint, which take a level keyword that a zero-argument display can't. coeftable returns a StatsBase.CoefTable (the ecosystem-standard, matching GLM.jl/MixedModels); confint returns a DataFrame.

Cox

  • Add coef / coefnames / vcov; coeftable (with exp(coef) and its confidence interval on the hazard-ratio scale, matching R's summary(coxph)) and confint.
  • Terse show (method, n, events, loglik/AIC/BIC, coefficients). The O(n²) C-index is no longer computed in show — it stays available via harrells_c.
  • Remove summary(::Cox) (Remove summary(::Cox): it overloads Base.summary with non-idiomatic (R-style) semantics #79): it overloaded Base.summary, whose contract is a one-line descriptor, with a full R-style table.

GeneralHazardModel (#78)

Previously had no show at all — it fell back to Julia's default struct dump (every data matrix printed).

  • Add coefnames, coeftable, confint, and a terse show.
  • coeftable/confint cover the covariate effects only; baseline distribution parameters are shown by show as the fitted distribution, not tested — a null of zero is the question for a covariate effect but not for a baseline shape/scale.
  • The GH model's two coefficient sets are grouped and labelled by role (hazard-level vs time-scale), since a covariate can enter both; PH/AFT/AH expose their single active block.

KaplanMeier

Shared / tests / docs

  • _coef_fmt, _ci_levstr, _hr_coeftable factored into utils.jl so Cox and the parametric models build identical tables.
  • Reference-string tests via repr(MIME"text/plain"(), m) for each model class (deterministic direct-construction / StableRNG fits), plus coeftable/confint structure and relationship checks.
  • Docs updated: cox.md (summarycoeftable/confint), fitting.md (GHM coeftable/confint), example.md (each parametric class now displays its show).

734 tests pass; docs build locally.

…urv#78, JuliaSurv#79)

Give every model class a terse, faithful `show` (MIME"text/plain") plus an
explicit `coeftable`/`confint` inference layer. Following the print-vs-summary
convention: `show` renders stored state (coefficients, baseline, fit statistics)
and never computes covariance-derived quantities; inference is requested
explicitly via `coeftable`/`confint`, which take a `level`.

Cox:
- Add coef/coefnames/vcov; coeftable (with exp(coef) and a hazard-ratio-scale CI,
  matching summary(coxph)) and confint. Terse show; drop the O(n^2) C-index from
  show (still available via harrells_c).
- Remove summary(::Cox) (JuliaSurv#79): it overloaded Base.summary with non-idiomatic
  R-style semantics.

GeneralHazardModel (JuliaSurv#78, previously fell back to the default struct dump):
- Add coefnames, coeftable, confint, and a terse show.
- coeftable/confint cover the covariate effects only; baseline parameters are
  shown as the fitted distribution, not tested. GH's two coefficient sets are
  grouped/labelled by role (hazard-level vs time-scale).

KaplanMeier:
- Add a show (n, events, median survival) replacing the struct dump.
- Reject right-hand-side variables in fit (single-curve estimator; avoids a
  silent pooled curve). Stratification tracked in JuliaSurv#83.

Shared _coef_fmt/_ci_levstr/_hr_coeftable in utils.jl; docs and reference-string
tests (repr(MIME"text/plain")) for each model class.
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.14286% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.12%. Comparing base (086fb1e) to head (68a51ba).

Files with missing lines Patch % Lines
src/Parametric/GeneralHazard.jl 72.60% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #84      +/-   ##
==========================================
- Coverage   92.32%   92.12%   -0.20%     
==========================================
  Files          12       12              
  Lines         873      978     +105     
==========================================
+ Hits          806      901      +95     
- Misses         67       77      +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lrnv
lrnv merged commit 5d3d859 into JuliaSurv:main Jul 15, 2026
3 of 5 checks passed
@andreasnoack
andreasnoack deleted the model-show-methods branch July 18, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GHM] No show method — REPL prints raw field dump instead of a coefficient summary

2 participants