Example 8.28: should we buy snowstorm insurance?

[This article was first published on SAS and R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

It’s been a long winter so far in New England, with many a snow storm. In this entry, we consider a simulation to complement the analytic solution for a probability problem concerning snow.

Consider a company that buys a policy to insure its revenue in the event of major snowstorms that shut down business. The policy pays nothing for the first such snowstorm of the year and $10,000 for each one thereafter, until the end of the year. The number of major snowstorms per year that shut down business is assumed to have a Poisson distribution with mean 1.5. What is the expected amount paid to the company under this policy during a one-year period?

Let SNOW be the number of snowstorms, and pay the amount paid out by the insurance. The following chart may be useful in discerning the patttern:
SNOW    PAY     10000*(snow-1)
0       0      -10000
1       0       0
2       10000   10000
3       20000   20000

The analytic solution is straightforward, but involves a truncation of the first snowstorm. Since we can assume that the random variable SNOW ~ Poisson(1.5) we know that E[SNOW] = 1.5 and E[10000*(SNOW-1)] = 10000*E[snow] – 10000 = 15000 – 10000 = 5000.

E[PAY] is equal to E[10000*(SNOW-1]) + 10000*P(SNOW=0) so the exact answer is
10000*P(snow=0) + 15000 - 10000 =
10000*exp(-1.5) + 15000 - 10000 = $7231

Here the advantage of simulation is that it may provide a useful check on the results, as well as a ready measure of variability. In this situation, the code is quite simple, but the approach is powerful.

R
numsim = 1000000
snow = rpois(numsim, 1.5)
pay = snow - 1      # subtract one
pay[snow==0] = 0    # deal with the pesky P(snow=0)
sim = mean(pay*10000)
analytic = 10000*(dpois(0, 3/2) + 3/2 - 1)

Yielding the following:
> sim
[1] 7249.55
> analytic
[1] 7231.302


SAS
The simulation and analytic solutions are also straightforward in SAS. Here the analytic result is only calculated once

data snow_insurance;
do i = 1 to 1000000;
  nsnow = ranpoi(0, 1.5);
  payout = max(nsnow -1, 0) * 10000;
  output;
end;
analytic = 10000 * (cdf("POISSON", 0, 1.5) + 1.5 -1);
output;
run;

proc means data=snow_insurance mean;
  var payout analytic;
run;

This results in the following output:
Variable            Mean
------------------------
payout           7236.96
analytic         7231.30
------------------------

To leave a comment for the author, please follow the link and comment on their blog: SAS and R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)