I have been posting a lot here recently (here and here and here) as I work through Aki Vehtari’s workflow analysing substance use data.
It is a longitudinal hierarchical model examining the effects of amphetamine use at start of treatment on subsequent amphetamine use in the following year of treatment. outcome
is days of amphetamine in the previous 28 days. This is measured at start of treatment and then at least once (but sometimes more) during treatment. set
is the number of days it is possible to have used amphetamine at each measurement point (always 28). yearsFromStart
is a numeric indicator variable, indicating the time each measurement was taken, in years of treatment, all values between 0 and 1. ats_baseline
is the number of days of amphetamine use in the 28 days prior to starting treatment.
I have wound a long winding path through several models starting at Gaussian and ending with zero inflated beta binomial with a quadratic polynomial term, comparing each new model to the previous model with loo-cv and checking for prior-data conflicts using the powerscale_sensitivity()
function from the priorsense
package.
I have been trying to get my most recent model - which includes a random slope term - to work, and finally did with sufficient effective sample size and Rhat = 1.00 for all parameters. I had to use 7000 iterations of four chains (instead of the default 4 x 1000 in brms
) to get there. Model specification.
fit_zibetabinomial_quad_rs_ats <- brm(formula = bf(outcome | trials(set) ~ ats_baseline*poly(yearsFromStart,2) + (yearsFromStart | encID)),
data = workingDF,
family = zero_inflated_beta_binomial(),
prior = c(prior(normal(0, 5),
class = Intercept),
prior(normal(0, 5),
class = b),
prior(cauchy(0, 5),
class = sd)), # add prior on corr matrix
save_pars = save_pars(all=TRUE),
seed = 1234,
iter = 7e3,
refresh = 0,
cores = 4,
control = list(adapt_delta = 0.99))
Here is the output
Links: mu = logit; phi = identity; zi = identity
Formula: outcome | trials(set) ~ ats_baseline * poly(yearsFromStart, 2) + (yearsFromStart | encID)
Data: workingDF (Number of observations: 2301)
Draws: 4 chains, each with iter = 7000; warmup = 3500; thin = 1;
total post-warmup draws = 14000
Multilevel Hyperparameters:
~encID (Number of levels: 687)
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
sd(Intercept) 0.91 0.11 0.71 1.13 1.00 5782 9927
sd(yearsFromStart) 3.30 0.39 2.56 4.11 1.00 2891 6307
cor(Intercept,yearsFromStart) 0.91 0.08 0.71 1.00 1.00 759 2026
Regression Coefficients:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
Intercept -4.58 0.13 -4.84 -4.32 1.00 7221 10014
ats_baseline 0.21 0.02 0.17 0.25 1.00 4642 7479
polyyearsFromStart21 -20.51 3.85 -28.06 -13.00 1.00 10602 10617
polyyearsFromStart22 -8.54 2.64 -13.63 -3.21 1.00 15726 11672
ats_baseline:polyyearsFromStart21 -2.76 0.70 -4.16 -1.40 1.00 6527 9481
ats_baseline:polyyearsFromStart22 2.77 0.41 1.97 3.56 1.00 14359 10770
Further Distributional Parameters:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
phi 4.82 0.53 3.84 5.94 1.00 6821 9077
zi 0.07 0.02 0.02 0.12 1.00 8162 6562
Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
and Tail_ESS are effective sample size measures, and Rhat is the potential
scale reduction factor on split chains (at convergence, Rhat = 1).
The previous model, exactly the same except for the with no random slope term (i.e. with (1|encID)
(yearsFromStart|encID)
) sailed through: great Rhat and ESS, and no prior-data conflicts. The addition of that random slope however suddenly has prior-data conflicts for many of the parameters.
powerscale_sensitivity(fit_zibetabinomial_quad_rs_ats,
variable=variables(as_draws(fit_zibetabinomial_quad_rs_ats))[1:11]) %>%
tt() %>%
format_tt(num_fmt="decimal")
Up to now I have been using the approach of if there are no conflicts the model is good to go to the next step of posterior predictive checks etc. But now I am stuck. I have tried multiple difference version of these basic priors, including including a prior on the correlation matrix (which seems to be the problem) of the form prior(lkj(2), class = cor)
. But the conflicts remain. I wonder if I could get help: interpreting the meaning of the values in the ‘prior’ and ‘likelihood’ columns, using these to specify better priors maybe, or in fact any other advice.