R/computeRuin.R

Defines functions computeRuin

Documented in computeRuin

computeRuin <-
function(U0=NULL,theta=NULL,eps=NULL,alpha,beta){
    #Computes U0, theta or eps when the two other values are given
    #Uses Lundberg's exponential bound
    #U0: initial capital
    #theta: safety loading
    #eps: probability of ruin
    if(!is.null(theta)){
       R <- solveLund(alpha,beta,theta)
       if(R < 1e-6) stop("Safety loading is too small")
       if(is.null(U0)){
          U0 <- -log(eps)/R
       }else if(is.null(eps)){
           eps <- exp(-R*U0)}
    }else{
       R <- -log(eps)/U0
       if(R >= beta) stop("Initial capital is too small.")
       theta <- beta/(alpha*R)*((beta/(beta-R))^alpha-1)-1
    }
    list(LundbergExp=R,initialCapital=U0,safetyLoading=theta,ruinProb = eps)
}

Try the RcmdrPlugin.RiskDemo package in your browser

Any scripts or data that you put into this service are public.

RcmdrPlugin.RiskDemo documentation built on Nov. 13, 2023, 5:07 p.m.