I'm trying to visualize health insurance benefit options for my company to help others make a decision. I have a table like so:
| plan | ded | oop | exp_oop |
|------+------------+------+---------|
| a | 400 | 2100 | 17400 |
| b | 1300 | 2600 | 14300 |
| c | 2600 | 5200 | 28600 |
ded= deductible; expense level where 90% co-insurance kicks inoop= out of pocket maximumexp_oop= amount of medical expense at whichoopis reached
I want to plot cost to the employee vs. medical expenses incurred. Health insurance works in ranges...
cost = expenses for 0 < expenses < ded
cost = deductible + (0.10 x (expenses - ded)) for ded <= expenses < exp_oop
cost = oop for oop <= expenses <= infinity
How might I plot each of these ranges? Basically, one gets a line of slope = 1 for 0 to each plan's deductible, then a line of slope = 0.1 from x = deductible to x = oop, and then a line of slope = 0 from oop upward.
I'm not sure how to conditionally plot with ggplot2. If you'd like to use the above, here's reproducible code for these cutoffs:
dat <- data.frame(plan = c("a", "b", "c"), ded = c(400, 1300, 2600), oop = c(2100, 2600, 5200), exp_oop = c(17400, 14300, 28600))
Do I have to create the x/y values myself? In other words an intermediate table like so?
| plan | x | y |
|------+-------+------|
| 1 | 0 | 0 |
| 1 | 400 | 400 |
| 1 | 17400 | 2100 |
| 2 | 0 | 0 |
| 2 | 1300 | 1300 |
| 2 | 14300 | 2600 |
| 3 | 0 | 0 |
| 3 | 2600 | 2600 |
| 3 | 28600 | 5200 |
I'm doing this for several variants (employee only, employee + spouse, etc.) so it would be great if I didn't need separate data tables for each plan but could just work with the already defined deductibles and out of pocket max values I already have in a data frame...
Thanks for any suggestions!




x<-0:some high valuefor each plan, probably usingapplyor similar.exp_oop, notoop.