1
$\begingroup$

I made a linear regression model to predict hospitalizations given health comorbidities (heart failure, cancer, COPD, etc) as below using pymc3:

with pm.Model() as model: 
    # Define priors

    intercept = pm.Normal.dist(mu=model_data['AVE_IP_ADM_PA_EQ_12'].mean(),
                               sigma=model_data['AVE_IP_ADM_PA_EQ_12'].std())

    pm.glm.GLM.from_formula('AVE_IP_ADM_PA_EQ_12 ~ BENE_SEX_IDENT_CD + BENE_AGE_CAT_CD + \
                            CC_ALZHDMTA + CC_CANCER + CC_CHF + CC_CHRNKIDN + \
                            CC_COPD + CC_DEPRESSN + CC_DIABETES + CC_ISCHMCHT + \
                            CC_OSTEOPRS + CC_RA_OA + CC_STRKETIA', model_data, 
                            priors={'Intercept': intercept})

    trace = pm.sample(5000, cores=2, tune=1000)

In addition to my predictors, the model creates an sd variable, which I presume to mean standard deviation.

I am trying to use this model to predict the number of hospitalizations of a theoretical patient populations, so I am trying to sample from the posteriors for each variable and calculated E(hospitalizations) like so:

E(hospitalizations) = coeff_i*comorbidities + intercept

Where comorbidities is either 1 or 0 based on the presence or absence and the coefficients I sample from the posteriors in my model. I will similarly sample from the intercept as well.

My question is how do I properly utilize the sd distribution? Do I think of this as an error term and draw from it and then either add or subtract it to my estimated value E(hospitalizations) above? Thank you!

Edit:

I think I figure it out -- leaving this post up in case anyone searches for this in the future.

To utilize sd when making a prediction, you would calculate your mean as coeff_i*comorbidities + intercept then use sd as the standard deviation in the posterior distribution for E(hospitalization).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.