Comments (4)
If your postererior_predictive is InferenceData
type, then try something like: az.plot_dist(posterior_pred_values.sum('y_obs_dim_0').isel(chain=0).y_obs)
. Each observation is a Bernoulli, but there is a coordinate y_obs_dim_0
(or something similar) whose length is the number of trials. If you sum over this axes, then you get Binomial samples with n=20 (or however many samples were in your observed data used for the likelihood function).
from bookcode_edition1.
Thank-you, @brendan-m-murphy that was very helpful.
The following with var_names
appears to work in PyMC 5:
pred_dists = (
pm.sample_prior_predictive(1000, model).prior_predictive["y_obs"],
pm.sample_posterior_predictive(idata, model, var_names = ["y_obs"])
)
Likewise,
pm.sample_prior_predictive(1000, model, var_names=["y_obs"]).prior_predictive
with the var_names
arg seems to work as well.
Cheers,
Avram
from bookcode_edition1.
Is there erratum for the book using the pymc
library?
The book code on page 12 (Code 1.7) below gives an error of: KeyError: 'y_obs'
pred_dists = (
pm.sample_prior_predictive( 1000, model)["y_obs"],
pm.sample_posterior_predictive(idata, 1000, model)["y_obs"]
)
from bookcode_edition1.
@aaelony The "sample_ ... _predictive" functions return arviz inference data, so you need to use e.g. pm.sample_prior_predictive(1000, model).prior_predictive["y_obs"]
(I think.)
Also, for PyMC 5, it seems like you need to use pm.sample_posterior_predictive(idata, model)
. There is no argument to specify the number of samples (I think it just gives you the same number of posterior predictive samples as samples in the idata, so 1000 samples per chain by default).
from bookcode_edition1.
Related Issues (20)
- Missing dataset: 8M10 HOT 8
- More documentation for run_mcmc_simple
- Missing p in equation
- Manuscript Error: Code 1.7 doesn't work in PyMC version 5 HOT 2
- Manuscript Error:
- No install file
- Bayesian Structural Time Series - Code adjusments
- Manuscript Error: Mismatch - Chapter 8 book code to notebook code in rvs function
- Manuscript Error: Code 6.15 vs Equation 6.7 HOT 1
- Issue on page /markdown/chp_11.html (imprecise example of 0 probability)
- Type Error on import of Tensorflow Code Block 3.7 Chapter 03 HOT 1
- Manuscript Error: HOT 3
- Manuscript Error:
- Code for Figure 2.7 not working with PYMC5
- Are solutions available to exercises?
- Fix TFP Code
- Solution of question 5M16 BMCP
- Better reference to scientific citation data in Problem 8M9
- Manuscript Error: HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bookcode_edition1.