-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* question * somewhat better * took it out * tout en vrac * back to the formula in relsurv -- results differ IDK why. * coment * up on ratetable branch * Typo * remove old version * dunno what to do with the output * some docs * question * somewhat better * took it out * tout en vrac * back to the formula in relsurv -- results differ IDK why. * coment * up on ratetable branch * Typo * some docs * remove old version * dunno what to do with the output * remove useless comments * upgrade RateTables dependency * error * correct tet * last push * docs --------- Co-authored-by: Oskar Laverny <[email protected]>
- Loading branch information
Showing
9 changed files
with
115 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
struct Nessie | ||
expected_sample_size::Vector{Float64} | ||
expected_life_time::Float64 | ||
grid::Vector{Float64} | ||
function Nessie(T, Δ, age, year, rate_preds, ratetable) | ||
annual_grid = 0:RateTables.RT_DAYS_IN_YEAR:maximum(T) | ||
exp_spl_size = zeros(length(annual_grid)) | ||
exp_life_time = 0.0 | ||
for i in eachindex(age) | ||
Lᵢ = Life(ratetable[rate_preds[i,:]...], age[i], year[i]) | ||
for j in eachindex(annual_grid) | ||
exp_spl_size[j] += ccdf(Lᵢ, annual_grid[j]) | ||
end | ||
exp_life_time += expectation(Lᵢ) | ||
end | ||
return new(exp_spl_size, exp_life_time / RateTables.RT_DAYS_IN_YEAR / length(age), annual_grid) | ||
end | ||
end | ||
|
||
""" | ||
nessie | ||
To call this function, use the formula below: | ||
nessie(@formula(Surv(time,status)~covariate), data, ratetable) | ||
""" | ||
function nessie(args...) | ||
r = fit(Nessie,args...) | ||
if (typeof(r)<:Nessie) | ||
return r | ||
end | ||
transform!(r, :estimator => ByRow(x-> (x.grid, x.expected_life_time, x.expected_sample_size)) => [:grid, :expected_life_time,:expected_sample_size]) | ||
select!(r, Not(:estimator)) | ||
|
||
lt = deepcopy(r) | ||
select!(lt, Not([:expected_sample_size, :grid])) | ||
|
||
select!(r, Not(:expected_life_time)) | ||
return lt, r | ||
end | ||
|
||
# Maybe not necessary ? No need to clutter the interface too much.. | ||
expected_life_time(x::Nessie) = x.expected_life_time | ||
expected_sample_size(x::Nessie) = x.expected_sample_size |
This file contains 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
This file contains 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