Closed pgrinaway closed 9 years ago
Multivariate nodes are updated as a single unit. Metropolis is one-at-a-time in terms of the nodes in the graph, but if a node is multivariate, all the elements are sampled together. In other words, proposals are drawn of size k, and accepted/rejected simultaneously. Have a peek at the propose method.
Sorry, perhaps I misspoke. I suppose the pressing question is this:
I have a model with array-valued parameters, and so PyMC samples using one-at-a-time Metropolis. What happens to the individual accept/rejects for each parameter? Should those not also be samples?
If I am not still misunderstanding: One Metropolis step entails a sweep through all the parameters. At the end of that sweep, each parameter will have one sample for that step, not n_parameters
samples.
At the end of the MCMC run, there will be n_parameters
traces, each containing n_iterations
samples.
Ok, that explains it. Thanks!
Apologies for any ignorance here, but I'm confused as to how, exactly, PyMC samples a multivariate model.
If I request (for example) 10 samples, a profiler indicates that the likelihood is evaluated ~140 times (approximately
n_parameters * n_iterations
). Now, I know there was a question and answer here, but there are a still a few confusing points.The documentation suggests that
Correct me if I'm wrong, but this sounds like drawing
n_parameters
samples from a multivariate distribution with a diagonal covariance matrix, then proposing them all at once. Why would this require so many likelihood evaluations?Looking at the docstrings in the code, the
Metropolis
StepMethod
seems to:Watching the verbose output, this makes sense, as it seems to be updating only one parameter at a time. If this is the case, though, shouldn't I get a sample for each accept/reject step? That is, shouldn't I then have
n_parameters * n_iterations
samples? Or am I mistaken as to how one at a time Metropolis works?Thanks so much for all your help, and apologies for any ignorant/stupid questions.