Skip to content

Commit

Permalink
[docs] Rudimentary documentation (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
lrnv authored Jun 8, 2024
1 parent a10eaf9 commit 0a304e6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ CurrentModule = SurvivalBase

# SurvivalBase

Documentation for [SurvivalBase](https://github.com/JuliaSurv/SurvivalBase.jl).
The [`SurvivalBase.jl`](https://github.com/JuliaSurv/SurvivalBase.jl) package is intended to hold internals and shared infrastructure for several other front-facing packages in the [JuliaSurv](https://github.com/JuliaSurv) organization, while having the minimal set of dependencies. Please do not use it directly and instead used other front-facing packages and interfaces from the organization.

Right now, the main infrastructure consists of special functions `Surv` and `Strata` used in [`StatsModels.jl`](https://juliastats.org/StatsModels.jl/stable/api/)'s `@formula`s to be able to express as formulas strandard survival models.

The current implementation only provides bindings for right censored survivals times (with `Surv(T,Δ)`, left-hand-side of formulas) and *stratified* estimators (with `Strata(x)`, right-hand-side of formulas), but extensions to more complex survival times (e.g. truncation and/or censoring from right and/or left) is planned (note: it would be straightforward and non-breaking).


```@index
```
Expand Down
11 changes: 11 additions & 0 deletions src/Strata.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
"""
Strata(x::Symbol)
Create a `StrataTerm` object that holds a variable in the construction of a formula to stratify an estimator.
The behavior of the stratification depends on the fitted estimator: is is usally used on the right hand side of formulas from [`StatsModels.jl`](https://github.com/JuliaStats/StatsModels.jl) as
@formula(Surv(time,status) ~ Strata(covariate1) + covariate 2)
It then has a behavior that unufortunately heavily depends on the estimator, e.g. stratification of a log-rank-type test.
"""
Strata(x) = x
struct StrataTerm{X} <: AbstractTerm
Covariable::X
Expand Down
11 changes: 11 additions & 0 deletions src/Surv.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
"""
Surv(T::Symbol, Δ::Symbol)
Create a `SurvTerm` object that holds a tuple of variables `(T,Δ)` in the construction of a formula, usually on the left-hand-side, representing a right-censored output time `T` with its status indicatrix `Δ`: Δ being true means that the time was indeed observed, while false means censoring.
This information, usually on the left hand side a formula, has then a behavior that may depend on the estimator. It allows to use formulas from [`StatsModels.jl`](https://github.com/JuliaStats/StatsModels.jl) as follow:
@formula(Surv(time,status) ~ covariate1 + covariate 2)
This usage is common in, e.g., cox models. However, note that the *meaning* of the formula heavily depends on the model : for hazard regession and maximum likelyhood estimation, this does not mean the same thing.
"""
Surv(T::Float64, Δ::Bool) = (T, Δ)
struct SurvTerm{X, Y} <: AbstractTerm
T::X
Expand Down

2 comments on commit 0a304e6

@lrnv
Copy link
Member Author

@lrnv lrnv commented on 0a304e6 Jun 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/108545

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" 0a304e65065b078d42055eb960a394934b20780b
git push origin v0.1.0

Please sign in to comment.