Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nessie #47

Merged
merged 30 commits into from
May 23, 2024
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ba34ddb
question
rimhajal May 14, 2024
c7168a7
somewhat better
rimhajal May 14, 2024
d26a29b
took it out
rimhajal May 14, 2024
4f4babf
tout en vrac
lrnv May 14, 2024
7978130
back to the formula in relsurv -- results differ IDK why.
lrnv May 14, 2024
add3414
coment
lrnv May 14, 2024
6e98466
up on ratetable branch
lrnv May 14, 2024
03dbafb
Typo
lrnv May 15, 2024
a315b5e
remove old version
lrnv May 16, 2024
31441dc
dunno what to do with the output
lrnv May 16, 2024
0de4cb5
some docs
rimhajal May 16, 2024
35b9b36
Merge branch 'nessie' of https://github.com/JuliaSurv/NetSurvival.jl …
rimhajal May 16, 2024
7f9becd
question
rimhajal May 17, 2024
c254835
somewhat better
rimhajal May 17, 2024
e9070b7
took it out
rimhajal May 17, 2024
68deffd
tout en vrac
lrnv May 17, 2024
b497a91
back to the formula in relsurv -- results differ IDK why.
lrnv May 17, 2024
b4d7c7e
coment
lrnv May 17, 2024
e7dbf0b
up on ratetable branch
lrnv May 17, 2024
f4554b3
Typo
lrnv May 17, 2024
39e26fa
some docs
rimhajal May 17, 2024
520b33e
remove old version
lrnv May 17, 2024
b8c53c5
dunno what to do with the output
lrnv May 17, 2024
d51d237
remove useless comments
rimhajal May 17, 2024
000568d
upgrade RateTables dependency
rimhajal May 17, 2024
be48fec
error
rimhajal May 17, 2024
225a6a7
correct tet
lrnv May 17, 2024
c4f4bd2
Merge branch 'nessie' of https://github.com/JuliaSurv/NetSurvival.jl …
rimhajal May 21, 2024
6c32f2a
last push
rimhajal May 21, 2024
1409ec8
docs
rimhajal May 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
up on ratetable branch
lrnv committed May 14, 2024
commit 6e9846629771370807f6fb9209b9e5dd5a067706
28 changes: 11 additions & 17 deletions src/Nessie.jl
Original file line number Diff line number Diff line change
@@ -3,26 +3,17 @@ struct Nessie
expected_life_time::Float64
grid::Vector{Float64}
function Nessie(T, Δ, age, year, rate_preds, ratetable)
grid = mk_grid([1,maximum(T)],1) # mk_grid(T,1)
exp_spl_size = zeros(length(grid))
life_time = 0.0
annual_grid = 1:365.241:maximum(T)
exp_spl_size = zeros(length(annual_grid))
exp_life_time = 0.0
for i in eachindex(age)
Λₚ = 0.0
rtᵢ = ratetable[rate_preds[i,:]...]
for j in 1:(length(grid)-1)
Sₚ = exp(-Λₚ)
λₚ = daily_hazard(rtᵢ, age[i] + grid[j], year[i] + grid[j])
∂Λₚ = λₚ * (grid[j+1]-grid[j]) # λₚ * ∂t
Λₚ += ∂Λₚ
exp_spl_size[j] += Sₚ
life_time += Sₚ * (1 - exp(-∂Λₚ)) / λₚ # see relsurv, netwei.c l 200.
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

exp_life_time = life_time / 365.241 / length(age)
annually = [searchsortedlast(grid, i) for i in (365.241 * (0:floor(maximum(T)/365.241))).+1]

return new(exp_spl_size[annually], exp_life_time, grid[annually])
return new(exp_spl_size, exp_life_time / 365.241 / length(age), annual_grid)
end
end

@@ -34,6 +25,9 @@ bla bla
"""
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))