Skip to content

Commit

Permalink
[internals] Pimp up pohar perme (#58)
Browse files Browse the repository at this point in the history
* pimp up the pohar perme for showcase

* oops
  • Loading branch information
lrnv authored May 24, 2024
1 parent b280366 commit 0a2e287
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/PoharPerme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,20 @@ References:
"""
const PoharPerme = NPNSEstimator{PoharPermeMethod}

function Λ!(::Type{PoharPermeMethod}, num_excess, den_excess, num_pop, den_pop, num_variance, T, Δ, age, year, rate_preds, ratetable, grid, ∂t)
function Λ!(::Type{PoharPermeMethod}, ∂Nₑ, Yₑ, ∂Nₚ, Yₚ, ∂V, T, Δ, age, date, rate_preds, ratetable, grid, ∂t)
for i in eachindex(age)
Tᵢ = searchsortedlast(grid, T[i])
Λₚ = 0.0
wₚ = 1.0
rtᵢ = ratetable[rate_preds[i,:]...]
Λₚ, wₚ, rtᵢ = 0.0, 1.0, ratetable[rate_preds[i,:]...]
for j in 1:Tᵢ
λₚ = daily_hazard(rtᵢ, age[i] + grid[j], year[i] + grid[j])
∂Λₚ = λₚ * ∂t[j]
Λₚ += ∂Λₚ
wₚ = exp(Λₚ)
num_pop[j] += ∂Λₚ * wₚ
den_excess[j] += wₚ
λₚ = daily_hazard(rtᵢ, age[i] + grid[j], date[i] + grid[j])
∂Λₚ = λₚ * ∂t[j]
Λₚ += ∂Λₚ
wₚ = exp(Λₚ)
∂Nₚ[j] += ∂Λₚ * wₚ
Yₑ[j] += wₚ
end
num_excess[Tᵢ] += wₚ * Δ[i]
num_variance[Tᵢ] += wₚ^2 * Δ[i]
∂Nₑ[Tᵢ] += wₚ * Δ[i]
∂V[Tᵢ] += wₚ^2 * Δ[i]
end
den_pop .= den_excess
Yₚ .= Yₑ
end

0 comments on commit 0a2e287

Please sign in to comment.