In PyMC, the "thin" argument seems no more in use. What can be put instead?

Trying to understand PyMC through examples, I made a small model referring to a set of birds weight (data observed: y20), supposedly coming from a normal population N(mu, sigma).

> import pymc as pm
> import arviz as az

> with pm.Model() as model:
>     
>     # Priors for unknown model parameters
>     mu = pm.Uniform('mu', lower = 0, upper = 2000)
>     sigma = pm.Uniform('sigma', lower = 0, upper = 100)
> 
>     # Likelihood of observations
>     lkd = pm.Normal('likelihood', mu = mu, sigma = sigma, observed = y20)
>     
>     # Expected value of outcome
>     weights = pm.Normal('weights', mu = mu, sigma = sigma)

This pm.Model() runs without problem. Now about sampling…

Browsing docs, I found in the “read the docs” tutorial, here: HERE, paragraph 3.5.1, the following sentence: MCMC often results in strong autocorrelation among samples that can result in imprecise posterior inference. To circumvent this, it is useful to thin the sample by only retaining every k th sample, where k is an integer value. This thinning interval is passed to the sampler via the thin argument.

So, after my model, I used this new line:

> with model:
>     trace = pm.sample(1000, tune = 1000, thin = 10)

and I got a strange consequence:


> ValueError: Unused step method arguments: {'thin'}

Has something changed in PyMC?

1 Like

Yes, thinning has fallen out of fashion. Mainly because it’s still better to keep auto-correlated samples than remove them. Really the only motivation to thin is to preserve memory. Moreover, modern samplers like NUTS tend to have very low auto-correlation.

You are referencing the out-of-date PyMC v2 docs. For up-to-date, see www.pymc.io.

Thanks twiecki for drawing my attention to the fact that I was referring to an older version.
I need to improve my way of trying to understand PyMC through examples… Your link to www.pymc.io will be very useful for me.

1 Like