With many thanks for help in why my exercise is using a Gamma distribution, I am still confused by another part.
The plot:
The commentary:
We may suspect from the above that there is some sort of exponential-like distribution at play here. ...The insurance claim charges may possibly be multimodal. The gamma distribution may be applicable and we could test this for the distribution of charges that weren't insurance claims first.
Then they calculate alpha and beta using what is apparently the standard method:
alpha = Mean(X)^2/Variance(X)
beta = Variance(X)/Mean(X)
and then they say:
we don't know if we have a best estimate for the population parameters, and we also only have a single estimate each for alpha and beta; we aren't capturing our uncertainty in their values. Can we take a Bayesian inference approach to estimate the parameters?
I kind of understand that. We want to simulate more values to work from. But why Exponential?
The code:
basic_model = pm.Model()
with basic_model:
# Priors for unknown model parameters
# alpha
alpha_ = pm.Exponential('alpha', alpha_est)
# beta
rate_ = pm.Exponential('rate', beta_est)
g = pm.Gamma('g', alpha=alpha_, beta=rate_,
observed=no_insurance)
trace = pm.sample(10000, nuts_kwargs=dict(target_accept=0.9))