Skip to content

Instantly share code, notes, and snippets.

@AustinRochford
Last active October 9, 2023 01:49
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save AustinRochford/bfc20cb3262169b41b730bd9faf74477 to your computer and use it in GitHub Desktop.
Save AustinRochford/bfc20cb3262169b41b730bd9faf74477 to your computer and use it in GitHub Desktop.
MRPyMC3-Multilevel Regression and Poststratification with PyMC3
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tmastny
Copy link

tmastny commented Nov 9, 2017

Great work! You mention that "all of the applications of MRP I have found online involve R's lme4 package or Stan." I've seen the MRP primer and Gelman and Hill's example in their book; do you have any other examples you could share?

@jaircastruita
Copy link

jaircastruita commented May 9, 2018

During cell 34, fitting the model, gives me the following error:

Bad initial energy: inf. The model might be misspecified. NaN occurred in optimization.

Could the dataset or the internals on library pyMC3 change enough to give this? I,m using pymc3 version 3.3 with python version 3.6

@nss2108
Copy link

nss2108 commented Nov 21, 2018

During cell 34, fitting the model, gives me the following error:

Bad initial energy: inf. The model might be misspecified. NaN occurred in optimization.

Could the dataset or the internals on library pyMC3 change enough to give this? I,m using pymc3 version 3.3 with python version 3.6

was this resolved? I got a similar result.

@jaircastruita
Copy link

jaircastruita commented Dec 7, 2018

Looks like new versions of PyMC3 used jittering as a default initializing method. To replicate the notebook exactly as it is you now have to specify which method you want, in this case NUTS using ADVI:

with model: trace = pm.sample(draws=1000, random_seed=SEED, nuts_kwargs=NUTS_KWARGS, init='advi', njobs=3)

Hope this works for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment