Search code examples
pymc3user-warning

userWarning pymc3 : What does reparameterize mean?


I built a pymc3 model using the DensityDist distribution. I have four parameters out of which 3 use Metropolis and one uses NUTS (this is automatically chosen by the pymc3). However, I get two different UserWarnings 1.Chain 0 contains number of diverging samples after tuning. If increasing target_accept does not help try to reparameterize. MAy I know what does reparameterize here mean? 2. The acceptance probability in chain 0 does not match the target. It is , but should be close to 0.8. Try to increase the number of tuning steps.

Digging through a few examples I used 'random_seed', 'discard_tuned_samples', 'step = pm.NUTS(target_accept=0.95)' and so on and got rid of these user warnings. But I couldn't find details of how these parameter values are being decided. I am sure this might have been discussed in various context but I am unable to find solid documentation for this. I was doing a trial and error method as below.

with patten_study: #SEED = 61290425 #51290425 step = pm.NUTS(target_accept=0.95) trace = sample(step = step)#4000,tune = 10000,step =step,discard_tuned_samples=False)#,random_seed=SEED)

I need to run these on different datasets. Hence I am struggling to fix these parameter values for each dataset I am using. Is there any way where I give these values or find the outcome (if there are any user warnings and then try other values) and run it in a loop?

Pardon me if I am asking something stupid!


Solution

  • In this context, re-parametrization basically is finding a different but equivalent model that it is easier to compute. There are many things you can do depending on the details of your model:

    • Instead of using a Uniform distribution you can use a Normal distribution with a large variance.
    • Changing from a centered-hierarchical model to a non-centered one.
    • Replacing a Gaussian with a Student-T
    • Model a discrete variable as a continuous
    • Marginalize variables like in this example

    whether these changes make sense or not is something that you should decide, based on your knowledge of the model and problem.