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

JET_fixes #56

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
23 changes: 12 additions & 11 deletions src/LifeContingencies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ struct SingleLife <: Life
fractional_assump
end

function SingleLife(;mort,issue_age=nothing,alive=true,fractional_assump = mt.Uniform())
function SingleLife(;mort=nothing,issue_age=nothing,alive=true,fractional_assump = mt.Uniform())
isnothing(mort) || ArgumentError("Need to pass a mortality vector to `mort` argument.")
return SingleLife(mort;issue_age,alive,fractional_assump)
end

Expand Down Expand Up @@ -99,7 +100,7 @@ abstract type JointAssumption end
"""
Frasier()

The assumption of independnt lives in a joint life calculation.
The assumption of independent lives in a joint life calculation.
Is a subtype of `JointAssumption`.
"""
struct Frasier <: JointAssumption end
Expand Down Expand Up @@ -252,7 +253,7 @@ end
"""
function N(lc::LifeContingency, from_time)
range = from_time:(omega(lc)-1)
return foldxt(+,Map(from_time->D(lc, from_time)), range)
return foldxt(+,range |> Map(from_time->D(lc, from_time)))
end

"""
Expand All @@ -263,7 +264,7 @@ Issue age is based on the issue_age in the LifeContingency `lc`.
"""
function M(lc::LifeContingency, from_time)
range = from_time:omega(lc)-1
return foldxt(+,Map(from_time->C(lc, from_time)), range)
return foldxt(+,range |> Map(from_time->C(lc, from_time)))
end

E(lc::LifeContingency, t, x) = D(lc,x + t) / D(lc,x)
Expand Down Expand Up @@ -403,7 +404,7 @@ end
"""
survival(Insurance)

The survorship vector for the given insurance.
The survivorship vector for the given insurance.
"""
function MortalityTables.survival(ins::Insurance)
return [survival(ins.life,t-1) for t in timepoints(ins)]
Expand Down Expand Up @@ -530,7 +531,7 @@ end

The net premium for a whole life insurance (without second argument) or a term life insurance through `to_time`.

The net premium is based on 1 unit of insurance with the death benfit payable at the end of the year and assuming annual net premiums.
The net premium is based on 1 unit of insurance with the death benefit payable at the end of the year and assuming annual net premiums.
"""
premium_net(lc::LifeContingency) = A(lc) / ä(lc)
premium_net(lc::LifeContingency,to_time) = A(lc,to_time) / ä(lc,to_time)
Expand Down Expand Up @@ -559,7 +560,7 @@ end
decrement(lc::LifeContingency,to_time)
decrement(lc::LifeContingency,from_time,to_time)

Return the probablity of death for the given LifeContingency.
Return the probability of death for the given LifeContingency.
"""
mt.decrement(lc::LifeContingency,from_time,to_time) = 1 - survival(lc.life,from_time,to_time)

Expand All @@ -568,7 +569,7 @@ mt.decrement(lc::LifeContingency,from_time,to_time) = 1 - survival(lc.life,from_
survival(lc::LifeContingency,from_time,to_time)
survival(lc::LifeContingency,to_time)

Return the probablity of survival for the given LifeContingency.
Return the probability of survival for the given LifeContingency.
"""
mt.survival(lc::LifeContingency,to_time) = survival(lc.life, 0, to_time)
mt.survival(lc::LifeContingency,from_time,to_time) = survival(lc.life, from_time, to_time)
Expand All @@ -577,7 +578,7 @@ mt.survival(l::SingleLife,to_time) = survival(l,0,to_time)
mt.survival(l::SingleLife,from_time,to_time) =survival(l.mort,l.issue_age + from_time,l.issue_age + to_time, l.fractional_assump)

"""
surival(life)
survival(life)

Return a survival vector for the given life.
"""
Expand All @@ -603,11 +604,11 @@ end
Yields.discount(lc::LifeContingency,t) = discount(lc.int,t)
Yields.discount(lc::LifeContingency,t1,t2) = discount(lc.int,t1,t2)

# function compostion with kwargs.
# function composition with kwargs.
# https://stackoverflow.com/questions/64740010/how-to-alias-composite-function-with-keyword-arguments
⋄(f, g) = (x...; kw...)->f(g(x...; kw...))

# unexported aliases
# un-exported aliases
const V = reserve_premium_net
const v = Yields.discount
const A = present_value ⋄ Insurance
Expand Down