Add show/coeftable/confint to models; KaplanMeier show (closes #78, #79)#84
Merged
Merged
Conversation
…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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Gives every model class a terse, faithful
showplus an explicitcoeftable/confintinference layer, and removes the non-idiomaticsummary(::Cox). Closes #78 and #79.The design follows the S/R print-vs-summary convention:
showrenders only stored state (coefficients, baseline, fit statistics) and never computes covariance-derived quantities; inference is requested explicitly viacoeftable/confint, which take alevelkeyword that a zero-argument display can't.coeftablereturns aStatsBase.CoefTable(the ecosystem-standard, matching GLM.jl/MixedModels);confintreturns aDataFrame.Cox
coef/coefnames/vcov;coeftable(withexp(coef)and its confidence interval on the hazard-ratio scale, matching R'ssummary(coxph)) andconfint.show(method, n, events, loglik/AIC/BIC, coefficients). The O(n²) C-index is no longer computed inshow— it stays available viaharrells_c.summary(::Cox)(Removesummary(::Cox): it overloadsBase.summarywith non-idiomatic (R-style) semantics #79): it overloadedBase.summary, whose contract is a one-line descriptor, with a full R-style table.GeneralHazardModel (#78)
Previously had no
showat all — it fell back to Julia's default struct dump (every data matrix printed).coefnames,coeftable,confint, and a terseshow.coeftable/confintcover the covariate effects only; baseline distribution parameters are shown byshowas the fitted distribution, not tested — a null of zero is the question for a covariate effect but not for a baseline shape/scale.hazard-levelvstime-scale), since a covariate can enter both; PH/AFT/AH expose their single active block.KaplanMeier
show(n, events, median survival) replacing the struct dump.fitnow errors on right-hand-side variables —KaplanMeieris a single-curve estimator, and silently returning a pooled curve for~ gis a footgun (R'ssurvfitstratifies). Stratification is tracked in [KaplanMeier] Support stratified estimation via formula RHS (grouped survival curves) #83; this error is the interim guardrail it refers to.Shared / tests / docs
_coef_fmt,_ci_levstr,_hr_coeftablefactored intoutils.jlso Cox and the parametric models build identical tables.repr(MIME"text/plain"(), m)for each model class (deterministic direct-construction /StableRNGfits), pluscoeftable/confintstructure and relationship checks.cox.md(summary→coeftable/confint),fitting.md(GHMcoeftable/confint),example.md(each parametric class now displays itsshow).734 tests pass; docs build locally.