Created
October 6, 2019 04:42
-
-
Save sneakers-the-rat/b13d67350a011c2929d5f1dd3d86fa9c to your computer and use it in GitHub Desktop.
UO's 'marginal' health insurance proposal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modeling this ridiculous healthcare proposal | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def healthcare(steps=11, initial_cost=2500000., mean_increase=6., sd_increase=2.): | |
# stash initial values | |
cost = initial_cost | |
uo_cost = cost*0.95 | |
increase_pct = 0. | |
uo_pct = 0.95 | |
# yield out the initial values | |
yield cost, uo_cost, increase_pct, uo_pct | |
step = 0 | |
while step < steps: | |
# randomly raise the damn costs ya filthy insurance company | |
increase_pct = np.random.normal(loc=mean_increase, scale=sd_increase) | |
increase_pct = increase_pct / 100. | |
increase = increase_pct*cost | |
# calculate the marginal increase | |
uo_increase = 0. | |
if increase_pct < 0: | |
# actually have no idea what happens if costs go down... | |
pass | |
if increase_pct < .02: | |
# straight up 95% | |
uo_increase += .95*increase | |
elif increase_pct < .03: | |
# take 95% of the first 2% | |
uo_increase += .95*.02*cost | |
# then 75% of the rest | |
uo_increase += .75*(increase_pct-.02)*cost | |
elif increase_pct < .05: | |
# etc. | |
uo_increase += .95*.02*cost | |
uo_increase += .75*.01*cost | |
uo_increase += .20*(increase_pct-.03)*cost | |
else: | |
# if above .05, | |
uo_increase += .95*.02*cost | |
uo_increase += .75*.01*cost | |
uo_increase += .20*.02*cost | |
cost += increase | |
uo_cost += uo_increase | |
uo_pct = uo_cost/cost | |
step += 1 | |
# yield em up | |
yield cost, uo_cost, increase_pct, uo_pct | |
def hc_costs(**kwargs): | |
# lil wrapper that yields a numpy array | |
hc_costs = [(cost, uo_cost, increase_pct, uo_pct) for | |
cost, uo_cost, increase_pct, uo_pct in healthcare(**kwargs)] | |
return np.row_stack(hc_costs) | |
def plot_costs(costs): | |
fig, ax = plt.subplots(3,1, gridspec_kw={'height_ratios':[2,1,1]}) | |
ax[0].plot(range(costs.shape[0]), costs[:,0], color='black') | |
ax[0].plot(range(costs.shape[0]), costs[:,1], color='blue') | |
ax[0].plot(range(costs.shape[0]), costs[:,0]-costs[:,1], color='red') | |
ax[0].set_title('Health Insurance Costs') | |
ax[0].legend(['Total Cost', 'UO Cost', 'GTFF Cost']) | |
ax[1].plot(range(costs.shape[0]), costs[:,3], color='black') | |
ax[1].set_title("Percent UO Contribution") | |
ax[2].plot(range(costs.shape[0]), costs[:, 2], color='black') | |
ax[2].set_title("Percent Annual Cost Increase") | |
plt.tight_layout() | |
plot_costs(hc_costs(initial_cost=2500000., steps=11, mean_increase=6, sd_increase=0)) | |
plot_costs(hc_costs(initial_cost=2500000., steps=11, mean_increase=6, sd_increase=4)) | |
plot_costs(hc_costs(initial_cost=2500000., steps=11, mean_increase=8, sd_increase=4)) | |
# calc mean increases | |
increases = [] | |
for i in range(500): | |
c = hc_costs(initial_cost=2500000., steps=11, mean_increase=8, sd_increase=4) | |
increases.append(c[5,0]-c[5,1]) | |
np.mean(increases) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment