I have the following program written in PyMC:
import pymc
from pymc.Matplot import plot as mcplot
def testit( passed, test_p = 0.8, alpha = 5, beta = 2):
Pi = pymc.Beta( 'Pi', alpha=alpha, beta=beta)
Tj = pymc.Bernoulli( 'Tj', p=test_p)
@pymc.deterministic
def flipper( Pi=Pi, Tj=Tj):
return Pi if Tj else (1-Pi)
# Pij = Pi if Tj else (1-Pi)
# return pymc.Bernoulli( 'Rij', Pij)
Rij = pymc.Bernoulli( 'Rij', p=flipper, value=passed, observed=True)
model = pymc.MCMC( [ Pi, Tj, flipper, Rij])
model.sample(iter=10000, burn=1000, thin=10)
mcplot(model)
testit( 1.)
It appears to be working properly, but I'd like to extract parameters from the posterior distributions. How can I get the posterior p
from Tj
and alpha
/beta
from Pi
?