Skip to content

Commit

Permalink
update docstring location, include estimation call
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannik Ammann committed Aug 9, 2023
1 parent 3ecf54b commit 5f85bfc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions docs/src/km.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ using Greenwood's formula:

```@docs
Survival.KaplanMeier
Survival.KaplanMeier(t::Real)
StatsAPI.fit(::Type{KaplanMeier}, ::Any, ::Any)
StatsAPI.confint(::KaplanMeier)
```
Expand Down
1 change: 1 addition & 0 deletions docs/src/na.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ from ``n_i`` samples:

```@docs
Survival.NelsonAalen
Survival.NelsonAalen(t::Real)
StatsAPI.fit(::Type{NelsonAalen}, ::Any, ::Any)
StatsAPI.confint(::NelsonAalen)
```
Expand Down
13 changes: 7 additions & 6 deletions src/kaplanmeier.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ Use `fit(KaplanMeier, ...)` to compute the estimates as `Float64`
values and construct this type.
Alternatively, `fit(KaplanMeier{S}, ...)` may be used to request a
particular value type `S` for the estimates.
"""
struct KaplanMeier{S,T} <: NonparametricEstimator
events::EventTable{T}
survival::Vector{S}
stderr::Vector{S}
end

"""
To computes the survival estimation at time `t` of a KaplanMeier fit you can use.
```julia
Expand All @@ -25,12 +32,6 @@ t = 5
km(t) # evaluates the estimator at time 5
```
"""
struct KaplanMeier{S,T} <: NonparametricEstimator
events::EventTable{T}
survival::Vector{S}
stderr::Vector{S}
end

function (km::KaplanMeier)(t::Real)
time_points = km.events.time
survival = km.survival
Expand Down
13 changes: 7 additions & 6 deletions src/nelsonaalen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ Use `fit(NelsonAalen, ...)` to compute the estimates as `Float64` values
and construct this type.
Alternatively, `fit(NelsonAalen{S}, ...)` may be used to request a
particular value type `S` for the estimates.
"""
struct NelsonAalen{S,T} <: NonparametricEstimator
events::EventTable{T}
chaz::Vector{S}
stderr::Vector{S}
end

"""
To computes the cumulative hazard estimation at time `t` of a NelsonAalen fit you can use.
```julia
Expand All @@ -25,12 +32,6 @@ t = 5
na(t) # evaluates the estimator at time 5
```
"""
struct NelsonAalen{S,T} <: NonparametricEstimator
events::EventTable{T}
chaz::Vector{S}
stderr::Vector{S}
end

function (na::NelsonAalen)(t::Real)
time_points = na.events.time
cumulative_hazard = na.chaz
Expand Down

0 comments on commit 5f85bfc

Please sign in to comment.