What does the vars argument actually do in the Metropolis sampler

The documentation says

  • vars ( list ) – List of variables for sampler

but is the intended effect when sampling? Or more bluntly put what’s the point of the argument and what’s it used for?

https://docs.pymc.io/api/inference.html#module-pymc3.step_methods.metropolis

P.S. I’m going for a really screwy inference run on purpose :slight_smile:

Example
https://github.com/arviz-devs/arviz_resources/blob/experiment/plots/WhatDoesVarsDo.ipynb

That’s for specifying the variable you want the sampler to sample. After you initialize a model, you can do model.free_vars which gives you a list of free parameters in your model. And then you can specify different sampler to sample different vars. For example see: https://docs.pymc.io/notebooks/sampling_compound_step.html

Thanks jungpenlao,

In the notebook then I specified vars=(mu,) but the sample seems to still be sampling the distribution of sd? My understanding is that pymc3 would only be sampling for value of mu but It looks like I’m mistaken

usually we passed vars=[mu] to it (not sure if it makes any differences tho)

Made the change but still confused. Also read the doc you sent but too dense to figure out what it means in reference to my confusion :frowning:

With vars specified still looks like ‘sd’ is still sampled. If I understand correctly only mu should be sampled? Or does the step argument in my case mean that ‘mu’ is sampled first?

Below is the graph from the notebook where I’m seeing 2 chains for both mu and sd leading to my confusion

Thank you for the help

Oh I see your confusion, all free parameters will be sampled or approximated, the var arg is to specify which sampler (eg metropolis) sample what (eg mu), otherwise it will be assigned automatically.

Ah ok that makes sense, So in this cause I could have mu sampled by MetropolisHastings and sd sampled by NUTS, for example

1 Like

Exactly.

1 Like

Thank you!