Skip to content

Commit

Permalink
took it out
Browse files Browse the repository at this point in the history
  • Loading branch information
rimhajal committed May 14, 2024
1 parent 99714c5 commit 45a43b2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Nessie.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function Nessie(formula::FormulaTerm, df::DataFrame, rate_preds, rt::RateTables.AbstractRateTable)
function Nessie(formula::FormulaTerm, df::DataFrame, rt::RateTables.AbstractRateTable)
formula_applied = apply_schema(formula,schema(df))
rate_predictors = String.([RateTables.predictors(rt)...])

nms = StatsModels.termnames(formula_applied.rhs)
if isa(nms, String)
Expand All @@ -21,19 +22,20 @@ function Nessie(formula::FormulaTerm, df::DataFrame, rate_preds, rt::RateTables.
for i in 1:nrow(unique(df[!,pred_names]))
for j in 1:nrow(new_df[i])
Tᵢ = searchsortedlast(times_d, new_df[i].time[j])
rate_preds = select(new_df[i],rate_predictors)
rtᵢ = rt[rate_preds[j,:]...]
Λₚ = 0.0

for m in 1:Tᵢ
λₚ = daily_hazard(rtᵢ, new_df[i].age[j] + times_d[m], new_df[i].year[j] + times_d[m])
∂Λₚ = λₚ #* (times_d[m+1]-times_d[m])
∂Λₚ = λₚ
Λₚ += ∂Λₚ
Sₚ = exp(-Λₚ)
num_pop[i,m] += Sₚ
sit[m] += (1-Sₚ) / λₚ
end
end
povp[i] = mean(sit ./ 365.241)
end
povp[i] = mean(sit ./ 365.241)
end
return num_pop, povp
end

0 comments on commit 45a43b2

Please sign in to comment.