I'm using PyMC 2.3.4 and am trying to get summary statistics for a subset of my model variables, but can't seem to do so using the method in the docs.
Model-building code:
import pymc
a = pymc.Normal('a',0,1)
b = pymc.Normal('b',0,1)
myModel = pymc.Model((a,b))
M = pymc.MCMC(myModel)
M.sample(1000)
Per the documentation at https://pymc-devs.github.io/pymc/database.html, I should be able to run
M.a.summary() -> summary statistics for a
but instead, I get
AttributeError: 'MCMC' object has no attribute 'a'
However, M.summary()
gives summary statistics for all variables.
There are perhaps too many ways to create a model in PyMC2. The one you used, passing an iterable of
pymc.Node
instances, does not record the names, so the model doesn't have anM.a
, even thoughM.nodes
contains a stochastic named 'a'.If you prefer to create your model this way, you can get a summary from
a
directly, withFor me, this prints
I find it convenient to have the attribute
M.a
available sometimes, and you can get it by using a dictionary instead of a list when constructing the model: