Large R-Hat Statistics

@pymc-bot

I received this warning when sampling my model:

The rhat statistic is larger than 1.01 for some parameters.

Should I loosen the priors to try and fix this? Here is my model:

with pm.Model() as promo_model:
    # Hyperpriors
    mu_global = pm.Normal('mu_global', mu=0, sigma=10)
    sigma_bl = pm.HalfNormal('sigma_bl', sigma=5)
    sigma_statc = pm.HalfNormal('sigma_statc', sigma=5)
    sigma_promo = pm.HalfNormal('sigma_promo', sigma=5)

    # Group-specific effects
    alpha_bl = pm.Normal('alpha_bl', mu=0, sigma=sigma_bl, shape=len(business_line_map))
    beta_statc = pm.Normal('beta_statc', mu=0, sigma=sigma_statc, shape=2)
    gamma_promo = pm.Normal('gamma_promo', mu=0, sigma=sigma_promo, shape=len(promo_type_map))

    # Expected mean
    mu = pm.Deterministic(
        'mu',
        mu_global + alpha_bl[bl_idx_promo] + beta_statc[statc_idx_promo] + gamma_promo[promo_idx_promo]
    )

    # Likelihood
    sigma = pm.HalfNormal('sigma', sigma=10)
    nu = pm.Exponential('nu', 1/30)
    likelihood = pm.StudentT('likelihood', nu=nu, mu=mu, sigma=sigma, observed=y_promo)


    # Posterior sampling
    trace_promo = pm.sample(1000, tune=1000, nuts_sampler="numpyro", return_inferencedata=True)

Have you tried any prior predictive checks on the model?

In my somewhat limited experience, this is always a good first step to verify that the model setup is sufficient for comparison with the observation. It often helps me answer questions about the suitability of priors etc…

Have you tried a non-centered parameterization of the hierarchical components? If your data plus prior are not very informative, it should work better than the centered parameterization you provided.

The doc # Likelihood occurs just before the priors, which could confuse readers.

Do you really expect nu to have a value of 30? If so, I’d suggest just replacing with a normal likelihood to simplify the computation. The model won’t change much because by the time you get a Student-t with 30 degrees of freedom it’s getting very close to a normal (which is the limit at infinite degrees of freedom).

Thanks Bob. I did non-centered parameterization, which fixed the r-hat but did still resulted in a bad energy plot with low BFMI. After a night of much needed sleep, I had to cut down on some of the features which were throwing the model off and now all looks great. Thank you for the help.

1 Like