'Coding a line with exponentially distributed random drops at Poisson distributed intervals

I'm trying to model the ruin rate for an insurance company that will be receiving claims of random amounts (that I'm assuming will be exponentially distributed) at random time intervals (that I'm assuming will be Poisson distributed).

I'm creating an index value of 100 for the initial holdings of the company and assuming that their assets grow at a constant rate of 5% per year and seeing how often ruin occurs when I change the different parameters in the Poisson and exponential distributions

All I have come up with so far is a table of values that takes the previous holdings from the company, multiplies it by 1.05 and takes away a scaled random exponentially distributed value. I've tried including some Poisson extension for arrival intervals but this doesn't seem to work well, so I've hashed it out. I'm struggling to then turn this into a line so it can be better visualised and also have the drops at random time intervals. Any help appreciated.

code thus far:

data3 <- data.frame(#arrival = rpois(50, lambda = 5),
                    size = rexp(50, rate = 50),
                    initial.holdings = rep(100,50)
                    )

for(i in 2:50){
  newcolname <- paste0("-", names(data3)[i])
  data3[[newcolname]] <- (data3[,i]*1.05 -100*rexp(50, rate = 20))
}


Solution 1:[1]

The random Poisson would be simulating the number of claims per year (with the expected number equal to lambda = 5). If the amount of each claim were exponentially distributed with the same rate parameter (20), the total claim amount per year would be gamma distributed with the shape parameter equal to the number of claims and the rate parameter the same as the underlying exponential. I'm not sure what the size column is supposed to represent.

Here is an implementation:

data3 <- setNames(
  as.data.frame(
    matrix(
      c(rep(100,50), 100*rgamma(49*50, rpois(49*50, 5), 20)), 50
    )
  ),
  c("initial.holdings", paste0("time", 1:49))
)

for (i in 2:50) {
  data3[,i] <- data3[,i - 1L]*1.05 - data3[,i]
}

With the distribution parameters selected (lambda = 5 and rate = 20), all simulation runs quickly go to ruin.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jblood94