I don't understand why MAP is giving error where as MCMC works fine in the same scenario? I am writing below the relevant part of code.
tau = Uniform('tau', lower=0.01, upper=5, doc='tau')
rv = [ Multinomial("rv"+str(i), count[i], prob_distribution[i], value = data[i], observed =True) for i in xrange(0, len(count)) ]
M = MAP([rv, tau])
M.fit()
tau_hat = M.tau.value()
Error: AttributeError: 'MAP' object has no attribute 'tau' (for the last line M.tau.value())
On the other hand if I use MCMC in place of MAP, it works fine :
m = MCMC([tau, rv])
m.sample(iter = 500)
print m.trace('tau')
I want the point estimate of tau at which posterior has max probability and compare it with Bayesian prediction (for which I use MCMC)
Some information about variables:
prob_distribution is a deterministic function which, given tau and some other information returns a list of predictive probability distribution for each game. I have around 200 games, so prob_distribution is a list of 200 lists (each containing probability distribution over actions for that game eg [0.4, 0.4, 0.2]
) Similarly count is a list of 200 numbers, count[i] denotes number of times ith
game was played. data[i] is the observed information for ith
game eg if data[i] = [10 10 6]
, count[i] will be 26
Additional note
If I include the following line:
model = Model([rv, tau])
then Irrsepective whether I use
M = MAP(model)
or m = MCMC(model)
this gives an error as follows:
TypeError: hasattr(): attribute name must be string
Can somebody please explain what is going on?