I'm trying to run a simple logistic regression on PyMC3. Here the code:

with pm.Model() as logistic_model:
    alpha=pm.Normal('alpha', mu=0, sd=100)
    beta1=pm.Normal('beta', mu=0, sd=100)
    beta2=pm.Normal('beta2', mu=0, sd=100)

    argtemp=alpha + beta1*data['age'].values +beta2*data['educ'].values
    Y_obs = pm.Bernoulli('Y_obs', p=prob, observed=data['income_more_50K'].values)
    map_estimate = pm.find_MAP()

    trace= pm.sample(40000, step=sampler, start=map_estimate)

The sampler run, but at the end it gives this error:

The gelman-rubin statistic is larger than 1.4 for some parameters. The sampler did not converge.
The estimated number of effective samples is smaller than 200 for some parameters.

Can someone help me in understanding what is wrong, and why the sampler do not converge?

Thank you!


1 Answer 1


It turns out that the problem was the MAP estimation. Commenting out that line makes the code works.

Details in this thread in the PyMC Discourse forum.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.