Hierarchical Multinomial Model taking days to run

Please also provide the following information in addition to your question:

  • Operating System:
    Ubuntu 19.10

  • brms Version:
    2.12.0

I am relatively new to Bayesian inference and brms has made the transition very approachable!

I am currently trying to analyze some multinomial data (8 possible categorical in each row) with a hierarchical model.

The data are generated from 16 groups of people (8 groups in “control”, 8 groups in "intervention) across 5 sessions, led by 2 different facilitators.

The model is taking a very long time to run. Most recently, I ran the model with 2 chains, for 2000 iterations with 1000 warmup iterations. The first chain took 19 hours, the second took 50 hours and still had a couple of divergent transitions and low ESS.

I’m wondering if Stan’s difficulty is from how I’ve specified the model, or if it’s just the complexity of the data leading to identifiability issues.

Is reparameterization something I could/should consider? Is this possible using the brms interface, or does it require directly coding in Stan?

My brms model is as follows:

library(tidyverse)
library(brms)

## Model formula
What_Multi_fmla <- bf(
  Codes | trials(Count) ~ Condition +
    Session_Type +
    Facilitator +
    Condition:Session_Type +
    Facilitator:Session_Type +
    (1 | Condition / Group)
)

# Parse data
Data <- read.csv("What_Wider.csv") %>%
  mutate(Tran_Type = ifelse(Session == "Instruction", NA, as.character(Tran_Type))) %>%
  unite("Session_Type", c(Session, Tran_Type)) %>%
  mutate(
    Group = factor(Group),
    Session_Type = str_remove(Session_Type, "_NA"),
    Session_Type = factor(
      Session_Type,
      levels = c(
        "Instruction",
        "Initial_Homecare",
        "Initial_Debrief",
        "Follow-up_Homecare",
        "Follow-up_Debrief"
      )
    )
  ) %>%
  
  droplevels() %>%
  data.frame()

## Bind outcome columns to use as dependent variable in multinomial analysis
What_Wider$Codes <-
  with(
    What_Wider,
    cbind(
      NoCode,
      Building,
      Caregiver,
      Patient,
      Patientpsych,
      SDOH,
      Canmeds,
      Expertise,
      Recommendations
    )
  )

The generated Stan code is as follows:
functions {

  /* multinomial-logit log-PMF
   * Args: 
   *   y: array of integer response values
   *   mu: vector of category logit probabilities
   * Returns:  
   *   a scalar to be added to the log posterior 
   */ 
   real multinomial_logit_lpmf(int[] y, vector mu) {
 return multinomial_lpmf(y | softmax(mu));
   }
}
data {
  int<lower=1> N;  // number of observations
  int<lower=2> ncat;  // number of categories
  int Y[N, ncat];  // response array
  int trials[N];  // number of trials
  int<lower=1> K_muBuilding;  // number of population-level effects
  matrix[N, K_muBuilding] X_muBuilding;  // population-level design matrix
  int<lower=1> K_muCaregiver;  // number of population-level effects
  matrix[N, K_muCaregiver] X_muCaregiver;  // population-level design matrix
  int<lower=1> K_muPatient;  // number of population-level effects
  matrix[N, K_muPatient] X_muPatient;  // population-level design matrix
  int<lower=1> K_muPatientpsych;  // number of population-level effects
  matrix[N, K_muPatientpsych] X_muPatientpsych;  // population-level design matrix
  int<lower=1> K_muSDOH;  // number of population-level effects
  matrix[N, K_muSDOH] X_muSDOH;  // population-level design matrix
  int<lower=1> K_muCanmeds;  // number of population-level effects
  matrix[N, K_muCanmeds] X_muCanmeds;  // population-level design matrix
  int<lower=1> K_muExpertise;  // number of population-level effects
  matrix[N, K_muExpertise] X_muExpertise;  // population-level design matrix
  int<lower=1> K_muRecommendations;  // number of population-level effects
  matrix[N, K_muRecommendations] X_muRecommendations;  // population-level design matrix
  // data for group-level effects of ID 1
  int<lower=1> N_1;  // number of grouping levels
  int<lower=1> M_1;  // number of coefficients per level
  int<lower=1> J_1[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_1_muBuilding_1;
  // data for group-level effects of ID 2
  int<lower=1> N_2;  // number of grouping levels
  int<lower=1> M_2;  // number of coefficients per level
  int<lower=1> J_2[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_2_muBuilding_1;
  // data for group-level effects of ID 3
  int<lower=1> N_3;  // number of grouping levels
  int<lower=1> M_3;  // number of coefficients per level
  int<lower=1> J_3[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_3_muCaregiver_1;
  // data for group-level effects of ID 4
  int<lower=1> N_4;  // number of grouping levels
  int<lower=1> M_4;  // number of coefficients per level
  int<lower=1> J_4[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_4_muCaregiver_1;
  // data for group-level effects of ID 5
  int<lower=1> N_5;  // number of grouping levels
  int<lower=1> M_5;  // number of coefficients per level
  int<lower=1> J_5[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_5_muPatient_1;
  // data for group-level effects of ID 6
  int<lower=1> N_6;  // number of grouping levels
  int<lower=1> M_6;  // number of coefficients per level
  int<lower=1> J_6[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_6_muPatient_1;
  // data for group-level effects of ID 7
  int<lower=1> N_7;  // number of grouping levels
  int<lower=1> M_7;  // number of coefficients per level
  int<lower=1> J_7[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_7_muPatientpsych_1;
  // data for group-level effects of ID 8
  int<lower=1> N_8;  // number of grouping levels
  int<lower=1> M_8;  // number of coefficients per level
  int<lower=1> J_8[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_8_muPatientpsych_1;
  // data for group-level effects of ID 9
  int<lower=1> N_9;  // number of grouping levels
  int<lower=1> M_9;  // number of coefficients per level
  int<lower=1> J_9[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_9_muSDOH_1;
  // data for group-level effects of ID 10
  int<lower=1> N_10;  // number of grouping levels
  int<lower=1> M_10;  // number of coefficients per level
  int<lower=1> J_10[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_10_muSDOH_1;
  // data for group-level effects of ID 11
  int<lower=1> N_11;  // number of grouping levels
  int<lower=1> M_11;  // number of coefficients per level
  int<lower=1> J_11[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_11_muCanmeds_1;
  // data for group-level effects of ID 12
  int<lower=1> N_12;  // number of grouping levels
  int<lower=1> M_12;  // number of coefficients per level
  int<lower=1> J_12[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_12_muCanmeds_1;
  // data for group-level effects of ID 13
  int<lower=1> N_13;  // number of grouping levels
  int<lower=1> M_13;  // number of coefficients per level
  int<lower=1> J_13[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_13_muExpertise_1;
  // data for group-level effects of ID 14
  int<lower=1> N_14;  // number of grouping levels
  int<lower=1> M_14;  // number of coefficients per level
  int<lower=1> J_14[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_14_muExpertise_1;
  // data for group-level effects of ID 15
  int<lower=1> N_15;  // number of grouping levels
  int<lower=1> M_15;  // number of coefficients per level
  int<lower=1> J_15[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_15_muRecommendations_1;
  // data for group-level effects of ID 16
  int<lower=1> N_16;  // number of grouping levels
  int<lower=1> M_16;  // number of coefficients per level
  int<lower=1> J_16[N];  // grouping indicator per observation
  // group-level predictor values
  vector[N] Z_16_muRecommendations_1;
  int prior_only;  // should the likelihood be ignored?
}
transformed data {
  int Kc_muBuilding = K_muBuilding - 1;
  matrix[N, Kc_muBuilding] Xc_muBuilding;  // centered version of X_muBuilding without an intercept
  vector[Kc_muBuilding] means_X_muBuilding;  // column means of X_muBuilding before centering
  int Kc_muCaregiver = K_muCaregiver - 1;
  matrix[N, Kc_muCaregiver] Xc_muCaregiver;  // centered version of X_muCaregiver without an intercept
  vector[Kc_muCaregiver] means_X_muCaregiver;  // column means of X_muCaregiver before centering
  int Kc_muPatient = K_muPatient - 1;
  matrix[N, Kc_muPatient] Xc_muPatient;  // centered version of X_muPatient without an intercept
  vector[Kc_muPatient] means_X_muPatient;  // column means of X_muPatient before centering
  int Kc_muPatientpsych = K_muPatientpsych - 1;
  matrix[N, Kc_muPatientpsych] Xc_muPatientpsych;  // centered version of X_muPatientpsych without an intercept
  vector[Kc_muPatientpsych] means_X_muPatientpsych;  // column means of X_muPatientpsych before centering
  int Kc_muSDOH = K_muSDOH - 1;
  matrix[N, Kc_muSDOH] Xc_muSDOH;  // centered version of X_muSDOH without an intercept
  vector[Kc_muSDOH] means_X_muSDOH;  // column means of X_muSDOH before centering
  int Kc_muCanmeds = K_muCanmeds - 1;
  matrix[N, Kc_muCanmeds] Xc_muCanmeds;  // centered version of X_muCanmeds without an intercept
  vector[Kc_muCanmeds] means_X_muCanmeds;  // column means of X_muCanmeds before centering
  int Kc_muExpertise = K_muExpertise - 1;
  matrix[N, Kc_muExpertise] Xc_muExpertise;  // centered version of X_muExpertise without an intercept
  vector[Kc_muExpertise] means_X_muExpertise;  // column means of X_muExpertise before centering
  int Kc_muRecommendations = K_muRecommendations - 1;
  matrix[N, Kc_muRecommendations] Xc_muRecommendations;  // centered version of X_muRecommendations without an intercept
  vector[Kc_muRecommendations] means_X_muRecommendations;  // column means of X_muRecommendations before centering
  for (i in 2:K_muBuilding) {
means_X_muBuilding[i - 1] = mean(X_muBuilding[, i]);
Xc_muBuilding[, i - 1] = X_muBuilding[, i] - means_X_muBuilding[i - 1];
  }
  for (i in 2:K_muCaregiver) {
means_X_muCaregiver[i - 1] = mean(X_muCaregiver[, i]);
Xc_muCaregiver[, i - 1] = X_muCaregiver[, i] - means_X_muCaregiver[i - 1];
  }
  for (i in 2:K_muPatient) {
means_X_muPatient[i - 1] = mean(X_muPatient[, i]);
Xc_muPatient[, i - 1] = X_muPatient[, i] - means_X_muPatient[i - 1];
  }
  for (i in 2:K_muPatientpsych) {
means_X_muPatientpsych[i - 1] = mean(X_muPatientpsych[, i]);
Xc_muPatientpsych[, i - 1] = X_muPatientpsych[, i] - means_X_muPatientpsych[i - 1];
  }
  for (i in 2:K_muSDOH) {
means_X_muSDOH[i - 1] = mean(X_muSDOH[, i]);
Xc_muSDOH[, i - 1] = X_muSDOH[, i] - means_X_muSDOH[i - 1];
  }
  for (i in 2:K_muCanmeds) {
means_X_muCanmeds[i - 1] = mean(X_muCanmeds[, i]);
Xc_muCanmeds[, i - 1] = X_muCanmeds[, i] - means_X_muCanmeds[i - 1];
  }
  for (i in 2:K_muExpertise) {
means_X_muExpertise[i - 1] = mean(X_muExpertise[, i]);
Xc_muExpertise[, i - 1] = X_muExpertise[, i] - means_X_muExpertise[i - 1];
  }
  for (i in 2:K_muRecommendations) {
means_X_muRecommendations[i - 1] = mean(X_muRecommendations[, i]);
Xc_muRecommendations[, i - 1] = X_muRecommendations[, i] - means_X_muRecommendations[i - 1];
  }
}
parameters {
  vector[Kc_muBuilding] b_muBuilding;  // population-level effects
  real Intercept_muBuilding;  // temporary intercept for centered predictors
  vector[Kc_muCaregiver] b_muCaregiver;  // population-level effects
  real Intercept_muCaregiver;  // temporary intercept for centered predictors
  vector[Kc_muPatient] b_muPatient;  // population-level effects
  real Intercept_muPatient;  // temporary intercept for centered predictors
  vector[Kc_muPatientpsych] b_muPatientpsych;  // population-level effects
  real Intercept_muPatientpsych;  // temporary intercept for centered predictors
  vector[Kc_muSDOH] b_muSDOH;  // population-level effects
  real Intercept_muSDOH;  // temporary intercept for centered predictors
  vector[Kc_muCanmeds] b_muCanmeds;  // population-level effects
  real Intercept_muCanmeds;  // temporary intercept for centered predictors
  vector[Kc_muExpertise] b_muExpertise;  // population-level effects
  real Intercept_muExpertise;  // temporary intercept for centered predictors
  vector[Kc_muRecommendations] b_muRecommendations;  // population-level effects
  real Intercept_muRecommendations;  // temporary intercept for centered predictors
  vector<lower=0>[M_1] sd_1;  // group-level standard deviations
  vector[N_1] z_1[M_1];  // standardized group-level effects
  vector<lower=0>[M_2] sd_2;  // group-level standard deviations
  vector[N_2] z_2[M_2];  // standardized group-level effects
  vector<lower=0>[M_3] sd_3;  // group-level standard deviations
  vector[N_3] z_3[M_3];  // standardized group-level effects
  vector<lower=0>[M_4] sd_4;  // group-level standard deviations
  vector[N_4] z_4[M_4];  // standardized group-level effects
  vector<lower=0>[M_5] sd_5;  // group-level standard deviations
  vector[N_5] z_5[M_5];  // standardized group-level effects
  vector<lower=0>[M_6] sd_6;  // group-level standard deviations
  vector[N_6] z_6[M_6];  // standardized group-level effects
  vector<lower=0>[M_7] sd_7;  // group-level standard deviations
  vector[N_7] z_7[M_7];  // standardized group-level effects
  vector<lower=0>[M_8] sd_8;  // group-level standard deviations
  vector[N_8] z_8[M_8];  // standardized group-level effects
  vector<lower=0>[M_9] sd_9;  // group-level standard deviations
  vector[N_9] z_9[M_9];  // standardized group-level effects
  vector<lower=0>[M_10] sd_10;  // group-level standard deviations
  vector[N_10] z_10[M_10];  // standardized group-level effects
  vector<lower=0>[M_11] sd_11;  // group-level standard deviations
  vector[N_11] z_11[M_11];  // standardized group-level effects
  vector<lower=0>[M_12] sd_12;  // group-level standard deviations
  vector[N_12] z_12[M_12];  // standardized group-level effects
  vector<lower=0>[M_13] sd_13;  // group-level standard deviations
  vector[N_13] z_13[M_13];  // standardized group-level effects
  vector<lower=0>[M_14] sd_14;  // group-level standard deviations
  vector[N_14] z_14[M_14];  // standardized group-level effects
  vector<lower=0>[M_15] sd_15;  // group-level standard deviations
  vector[N_15] z_15[M_15];  // standardized group-level effects
  vector<lower=0>[M_16] sd_16;  // group-level standard deviations
  vector[N_16] z_16[M_16];  // standardized group-level effects
}
transformed parameters {
  vector[N_1] r_1_muBuilding_1;  // actual group-level effects
  vector[N_2] r_2_muBuilding_1;  // actual group-level effects
  vector[N_3] r_3_muCaregiver_1;  // actual group-level effects
  vector[N_4] r_4_muCaregiver_1;  // actual group-level effects
  vector[N_5] r_5_muPatient_1;  // actual group-level effects
  vector[N_6] r_6_muPatient_1;  // actual group-level effects
  vector[N_7] r_7_muPatientpsych_1;  // actual group-level effects
  vector[N_8] r_8_muPatientpsych_1;  // actual group-level effects
  vector[N_9] r_9_muSDOH_1;  // actual group-level effects
  vector[N_10] r_10_muSDOH_1;  // actual group-level effects
  vector[N_11] r_11_muCanmeds_1;  // actual group-level effects
  vector[N_12] r_12_muCanmeds_1;  // actual group-level effects
  vector[N_13] r_13_muExpertise_1;  // actual group-level effects
  vector[N_14] r_14_muExpertise_1;  // actual group-level effects
  vector[N_15] r_15_muRecommendations_1;  // actual group-level effects
  vector[N_16] r_16_muRecommendations_1;  // actual group-level effects
  r_1_muBuilding_1 = (sd_1[1] * (z_1[1]));
  r_2_muBuilding_1 = (sd_2[1] * (z_2[1]));
  r_3_muCaregiver_1 = (sd_3[1] * (z_3[1]));
  r_4_muCaregiver_1 = (sd_4[1] * (z_4[1]));
  r_5_muPatient_1 = (sd_5[1] * (z_5[1]));
  r_6_muPatient_1 = (sd_6[1] * (z_6[1]));
  r_7_muPatientpsych_1 = (sd_7[1] * (z_7[1]));
  r_8_muPatientpsych_1 = (sd_8[1] * (z_8[1]));
  r_9_muSDOH_1 = (sd_9[1] * (z_9[1]));
  r_10_muSDOH_1 = (sd_10[1] * (z_10[1]));
  r_11_muCanmeds_1 = (sd_11[1] * (z_11[1]));
  r_12_muCanmeds_1 = (sd_12[1] * (z_12[1]));
  r_13_muExpertise_1 = (sd_13[1] * (z_13[1]));
  r_14_muExpertise_1 = (sd_14[1] * (z_14[1]));
  r_15_muRecommendations_1 = (sd_15[1] * (z_15[1]));
  r_16_muRecommendations_1 = (sd_16[1] * (z_16[1]));
}
model {
  // initialize linear predictor term
  vector[N] muBuilding = Intercept_muBuilding + Xc_muBuilding * b_muBuilding;
  // initialize linear predictor term
  vector[N] muCaregiver = Intercept_muCaregiver + Xc_muCaregiver * b_muCaregiver;
  // initialize linear predictor term
  vector[N] muPatient = Intercept_muPatient + Xc_muPatient * b_muPatient;
  // initialize linear predictor term
  vector[N] muPatientpsych = Intercept_muPatientpsych + Xc_muPatientpsych * b_muPatientpsych;
  // initialize linear predictor term
  vector[N] muSDOH = Intercept_muSDOH + Xc_muSDOH * b_muSDOH;
  // initialize linear predictor term
  vector[N] muCanmeds = Intercept_muCanmeds + Xc_muCanmeds * b_muCanmeds;
  // initialize linear predictor term
  vector[N] muExpertise = Intercept_muExpertise + Xc_muExpertise * b_muExpertise;
  // initialize linear predictor term
  vector[N] muRecommendations = Intercept_muRecommendations + Xc_muRecommendations * b_muRecommendations;
  // linear predictor matrix
  vector[ncat] mu[N];
  for (n in 1:N) {
// add more terms to the linear predictor
muBuilding[n] += r_1_muBuilding_1[J_1[n]] * Z_1_muBuilding_1[n] + r_2_muBuilding_1[J_2[n]] * Z_2_muBuilding_1[n];
  }
  for (n in 1:N) {
// add more terms to the linear predictor
muCaregiver[n] += r_3_muCaregiver_1[J_3[n]] * Z_3_muCaregiver_1[n] + r_4_muCaregiver_1[J_4[n]] * Z_4_muCaregiver_1[n];
  }
  for (n in 1:N) {
// add more terms to the linear predictor
muPatient[n] += r_5_muPatient_1[J_5[n]] * Z_5_muPatient_1[n] + r_6_muPatient_1[J_6[n]] * Z_6_muPatient_1[n];
  }
  for (n in 1:N) {
// add more terms to the linear predictor
muPatientpsych[n] += r_7_muPatientpsych_1[J_7[n]] * Z_7_muPatientpsych_1[n] + r_8_muPatientpsych_1[J_8[n]] * Z_8_muPatientpsych_1[n];
  }
  for (n in 1:N) {
// add more terms to the linear predictor
muSDOH[n] += r_9_muSDOH_1[J_9[n]] * Z_9_muSDOH_1[n] + r_10_muSDOH_1[J_10[n]] * Z_10_muSDOH_1[n];
  }
  for (n in 1:N) {
// add more terms to the linear predictor
muCanmeds[n] += r_11_muCanmeds_1[J_11[n]] * Z_11_muCanmeds_1[n] + r_12_muCanmeds_1[J_12[n]] * Z_12_muCanmeds_1[n];
  }
  for (n in 1:N) {
// add more terms to the linear predictor
muExpertise[n] += r_13_muExpertise_1[J_13[n]] * Z_13_muExpertise_1[n] + r_14_muExpertise_1[J_14[n]] * Z_14_muExpertise_1[n];
  }
  for (n in 1:N) {
// add more terms to the linear predictor
muRecommendations[n] += r_15_muRecommendations_1[J_15[n]] * Z_15_muRecommendations_1[n] + r_16_muRecommendations_1[J_16[n]] * Z_16_muRecommendations_1[n];
  }
  for (n in 1:N) {
mu[n] = [0, muBuilding[n], muCaregiver[n], muPatient[n], muPatientpsych[n], muSDOH[n], muCanmeds[n], muExpertise[n], muRecommendations[n]]';
  }
  // priors including all constants
  target += normal_lpdf(b_muBuilding[1] | 0,5);
  target += normal_lpdf(b_muBuilding[2] | 0,5);
  target += normal_lpdf(b_muBuilding[3] | 0,5);
  target += normal_lpdf(b_muBuilding[4] | 0,5);
  target += normal_lpdf(b_muBuilding[5] | 0,5);
  target += normal_lpdf(b_muBuilding[6] | 0,5);
  target += normal_lpdf(b_muBuilding[7] | 0,5);
  target += normal_lpdf(b_muBuilding[8] | 0,5);
  target += normal_lpdf(b_muBuilding[9] | 0,5);
  target += normal_lpdf(b_muBuilding[10] | 0,5);
  target += normal_lpdf(b_muBuilding[11] | 0,5);
  target += normal_lpdf(b_muBuilding[12] | 0,5);
  target += normal_lpdf(b_muBuilding[13] | 0,5);
  target += normal_lpdf(b_muBuilding[14] | 0,5);
  target += normal_lpdf(b_muCaregiver[1] | 0,5);
  target += normal_lpdf(b_muCaregiver[2] | 0,5);
  target += normal_lpdf(b_muCaregiver[3] | 0,5);
  target += normal_lpdf(b_muCaregiver[4] | 0,5);
  target += normal_lpdf(b_muCaregiver[5] | 0,5);
  target += normal_lpdf(b_muCaregiver[6] | 0,5);
  target += normal_lpdf(b_muCaregiver[7] | 0,5);
  target += normal_lpdf(b_muCaregiver[8] | 0,5);
  target += normal_lpdf(b_muCaregiver[9] | 0,5);
  target += normal_lpdf(b_muCaregiver[10] | 0,5);
  target += normal_lpdf(b_muCaregiver[11] | 0,5);
  target += normal_lpdf(b_muCaregiver[12] | 0,5);
  target += normal_lpdf(b_muCaregiver[13] | 0,5);
  target += normal_lpdf(b_muCaregiver[14] | 0,5);
  target += normal_lpdf(b_muPatient[1] | 0,5);
  target += normal_lpdf(b_muPatient[2] | 0,5);
  target += normal_lpdf(b_muPatient[3] | 0,5);
  target += normal_lpdf(b_muPatient[4] | 0,5);
  target += normal_lpdf(b_muPatient[5] | 0,5);
  target += normal_lpdf(b_muPatient[6] | 0,5);
  target += normal_lpdf(b_muPatient[7] | 0,5);
  target += normal_lpdf(b_muPatient[8] | 0,5);
  target += normal_lpdf(b_muPatient[9] | 0,5);
  target += normal_lpdf(b_muPatient[10] | 0,5);
  target += normal_lpdf(b_muPatient[11] | 0,5);
  target += normal_lpdf(b_muPatient[12] | 0,5);
  target += normal_lpdf(b_muPatient[13] | 0,5);
  target += normal_lpdf(b_muPatient[14] | 0,5);
  target += normal_lpdf(b_muPatientpsych[1] | 0,5);
  target += normal_lpdf(b_muPatientpsych[2] | 0,5);
  target += normal_lpdf(b_muPatientpsych[3] | 0,5);
  target += normal_lpdf(b_muPatientpsych[4] | 0,5);
  target += normal_lpdf(b_muPatientpsych[5] | 0,5);
  target += normal_lpdf(b_muPatientpsych[6] | 0,5);
  target += normal_lpdf(b_muPatientpsych[7] | 0,5);
  target += normal_lpdf(b_muPatientpsych[8] | 0,5);
  target += normal_lpdf(b_muPatientpsych[9] | 0,5);
  target += normal_lpdf(b_muPatientpsych[10] | 0,5);
  target += normal_lpdf(b_muPatientpsych[11] | 0,5);
  target += normal_lpdf(b_muPatientpsych[12] | 0,5);
  target += normal_lpdf(b_muPatientpsych[13] | 0,5);
  target += normal_lpdf(b_muPatientpsych[14] | 0,5);
  target += normal_lpdf(b_muSDOH[1] | 0,5);
  target += normal_lpdf(b_muSDOH[2] | 0,5);
  target += normal_lpdf(b_muSDOH[3] | 0,5);
  target += normal_lpdf(b_muSDOH[4] | 0,5);
  target += normal_lpdf(b_muSDOH[5] | 0,5);
  target += normal_lpdf(b_muSDOH[6] | 0,5);
  target += normal_lpdf(b_muSDOH[7] | 0,5);
  target += normal_lpdf(b_muSDOH[8] | 0,5);
  target += normal_lpdf(b_muSDOH[9] | 0,5);
  target += normal_lpdf(b_muSDOH[10] | 0,5);
  target += normal_lpdf(b_muSDOH[11] | 0,5);
  target += normal_lpdf(b_muSDOH[12] | 0,5);
  target += normal_lpdf(b_muSDOH[13] | 0,5);
  target += normal_lpdf(b_muSDOH[14] | 0,5);
  target += normal_lpdf(b_muCanmeds[1] | 0,5);
  target += normal_lpdf(b_muCanmeds[2] | 0,5);
  target += normal_lpdf(b_muCanmeds[3] | 0,5);
  target += normal_lpdf(b_muCanmeds[4] | 0,5);
  target += normal_lpdf(b_muCanmeds[5] | 0,5);
  target += normal_lpdf(b_muCanmeds[6] | 0,5);
  target += normal_lpdf(b_muCanmeds[7] | 0,5);
  target += normal_lpdf(b_muCanmeds[8] | 0,5);
  target += normal_lpdf(b_muCanmeds[9] | 0,5);
  target += normal_lpdf(b_muCanmeds[10] | 0,5);
  target += normal_lpdf(b_muCanmeds[11] | 0,5);
  target += normal_lpdf(b_muCanmeds[12] | 0,5);
  target += normal_lpdf(b_muCanmeds[13] | 0,5);
  target += normal_lpdf(b_muCanmeds[14] | 0,5);
  target += normal_lpdf(b_muExpertise[1] | 0,5);
  target += normal_lpdf(b_muExpertise[2] | 0,5);
  target += normal_lpdf(b_muExpertise[3] | 0,5);
  target += normal_lpdf(b_muExpertise[4] | 0,5);
  target += normal_lpdf(b_muExpertise[5] | 0,5);
  target += normal_lpdf(b_muExpertise[6] | 0,5);
  target += normal_lpdf(b_muExpertise[7] | 0,5);
  target += normal_lpdf(b_muExpertise[8] | 0,5);
  target += normal_lpdf(b_muExpertise[9] | 0,5);
  target += normal_lpdf(b_muExpertise[10] | 0,5);
  target += normal_lpdf(b_muExpertise[11] | 0,5);
  target += normal_lpdf(b_muExpertise[12] | 0,5);
  target += normal_lpdf(b_muExpertise[13] | 0,5);
  target += normal_lpdf(b_muExpertise[14] | 0,5);
  target += normal_lpdf(b_muRecommendations[1] | 0,5);
  target += normal_lpdf(b_muRecommendations[2] | 0,5);
  target += normal_lpdf(b_muRecommendations[3] | 0,5);
  target += normal_lpdf(b_muRecommendations[4] | 0,5);
  target += normal_lpdf(b_muRecommendations[5] | 0,5);
  target += normal_lpdf(b_muRecommendations[6] | 0,5);
  target += normal_lpdf(b_muRecommendations[7] | 0,5);
  target += normal_lpdf(b_muRecommendations[8] | 0,5);
  target += normal_lpdf(b_muRecommendations[9] | 0,5);
  target += normal_lpdf(b_muRecommendations[10] | 0,5);
  target += normal_lpdf(b_muRecommendations[11] | 0,5);
  target += normal_lpdf(b_muRecommendations[12] | 0,5);
  target += normal_lpdf(b_muRecommendations[13] | 0,5);
  target += normal_lpdf(b_muRecommendations[14] | 0,5);
  target += cauchy_lpdf(sd_1[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_1[1] | 0, 1);
  target += cauchy_lpdf(sd_2[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_2[1] | 0, 1);
  target += cauchy_lpdf(sd_3[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_3[1] | 0, 1);
  target += cauchy_lpdf(sd_4[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_4[1] | 0, 1);
  target += cauchy_lpdf(sd_5[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_5[1] | 0, 1);
  target += cauchy_lpdf(sd_6[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_6[1] | 0, 1);
  target += cauchy_lpdf(sd_7[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_7[1] | 0, 1);
  target += cauchy_lpdf(sd_8[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_8[1] | 0, 1);
  target += cauchy_lpdf(sd_9[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_9[1] | 0, 1);
  target += cauchy_lpdf(sd_10[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_10[1] | 0, 1);
  target += cauchy_lpdf(sd_11[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_11[1] | 0, 1);
  target += cauchy_lpdf(sd_12[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_12[1] | 0, 1);
  target += cauchy_lpdf(sd_13[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_13[1] | 0, 1);
  target += cauchy_lpdf(sd_14[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_14[1] | 0, 1);
  target += cauchy_lpdf(sd_15[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_15[1] | 0, 1);
  target += cauchy_lpdf(sd_16[1] | 0,1)
- 1 * cauchy_lccdf(0 | 0,1);
  target += normal_lpdf(z_16[1] | 0, 1);
  // likelihood including all constants
  if (!prior_only) {
for (n in 1:N) {
  target += multinomial_logit_lpmf(Y[n] | mu[n]);
}
  }
}
generated quantities {
  // actual population-level intercept
  real b_muBuilding_Intercept = Intercept_muBuilding - dot_product(means_X_muBuilding, b_muBuilding);
  // actual population-level intercept
  real b_muCaregiver_Intercept = Intercept_muCaregiver - dot_product(means_X_muCaregiver, b_muCaregiver);
  // actual population-level intercept
  real b_muPatient_Intercept = Intercept_muPatient - dot_product(means_X_muPatient, b_muPatient);
  // actual population-level intercept
  real b_muPatientpsych_Intercept = Intercept_muPatientpsych - dot_product(means_X_muPatientpsych, b_muPatientpsych);
  // actual population-level intercept
  real b_muSDOH_Intercept = Intercept_muSDOH - dot_product(means_X_muSDOH, b_muSDOH);
  // actual population-level intercept
  real b_muCanmeds_Intercept = Intercept_muCanmeds - dot_product(means_X_muCanmeds, b_muCanmeds);
  // actual population-level intercept
  real b_muExpertise_Intercept = Intercept_muExpertise - dot_product(means_X_muExpertise, b_muExpertise);
  // actual population-level intercept
  real b_muRecommendations_Intercept = Intercept_muRecommendations - dot_product(means_X_muRecommendations, b_muRecommendations);
}

I’m slowly attempting to work backwards to learn Stan from brms, but this relatively complex model has me at a loss.

Are there any corrections or optimizations that might help the sample run more efficiently in this case?

I have also attached the data:
What_Wider.csv (331.3 KB)

I specified the priors as follows (too many characters for the original post):

Specify verbose priors

what_priors <- c(
  set_prior("normal(0,5)",  
            class = "b",
            coef = "ConditionIntervention", 
            dpar = "muBuilding"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare", 
            dpar = "muBuilding"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief",
            dpar = "muBuilding"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare", 
            dpar = "muBuilding"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief",
            dpar = "muBuilding"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "FacilitatorFacilitator2", 
            dpar = "muBuilding"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Homecare", 
            dpar = "muBuilding"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Debrief", 
            dpar = "muBuilding"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Homecare", 
            dpar = "muBuilding"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Debrief", 
            dpar = "muBuilding"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare:FacilitatorFacilitator2", 
            dpar = "muBuilding"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief:FacilitatorFacilitator2", 
            dpar = "muBuilding"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare:FacilitatorFacilitator2", 
            dpar = "muBuilding"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief:FacilitatorFacilitator2", 
            dpar = "muBuilding"),
  
  set_prior("cauchy(0,1)",  
            class = "sd", 
            dpar = "muBuilding"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition", 
            dpar = "muBuilding"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition:Group",
            dpar = "muBuilding"),
  
  set_prior("normal(0,5)",  
            class = "b",
            coef = "ConditionIntervention", 
            dpar = "muCanmeds"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare", 
            dpar = "muCanmeds"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief",
            dpar = "muCanmeds"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare", 
            dpar = "muCanmeds"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief",
            dpar = "muCanmeds"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "FacilitatorFacilitator2", 
            dpar = "muCanmeds"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Homecare", 
            dpar = "muCanmeds"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Debrief", 
            dpar = "muCanmeds"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Homecare", 
            dpar = "muCanmeds"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Debrief", 
            dpar = "muCanmeds"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare:FacilitatorFacilitator2", 
            dpar = "muCanmeds"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief:FacilitatorFacilitator2", 
            dpar = "muCanmeds"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare:FacilitatorFacilitator2", 
            dpar = "muCanmeds"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief:FacilitatorFacilitator2", 
            dpar = "muCanmeds"),
  
  set_prior("cauchy(0,1)",  
            class = "sd", 
            dpar = "muCanmeds"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition", 
            dpar = "muCanmeds"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition:Group",
            dpar = "muCanmeds"),
  
  set_prior("normal(0,5)",  
            class = "b",
            coef = "ConditionIntervention", 
            dpar = "muCaregiver"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare", 
            dpar = "muCaregiver"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief",
            dpar = "muCaregiver"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare", 
            dpar = "muCaregiver"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief",
            dpar = "muCaregiver"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "FacilitatorFacilitator2", 
            dpar = "muCaregiver"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Homecare", 
            dpar = "muCaregiver"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Debrief", 
            dpar = "muCaregiver"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Homecare", 
            dpar = "muCaregiver"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Debrief", 
            dpar = "muCaregiver"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare:FacilitatorFacilitator2", 
            dpar = "muCaregiver"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief:FacilitatorFacilitator2", 
            dpar = "muCaregiver"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare:FacilitatorFacilitator2", 
            dpar = "muCaregiver"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief:FacilitatorFacilitator2", 
            dpar = "muCaregiver"),
  
  set_prior("cauchy(0,1)",  
            class = "sd", 
            dpar = "muCaregiver"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition", 
            dpar = "muCaregiver"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition:Group",
            dpar = "muCaregiver"),
  
  set_prior("normal(0,5)",  
            class = "b",
            coef = "ConditionIntervention", 
            dpar = "muExpertise"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare", 
            dpar = "muExpertise"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief",
            dpar = "muExpertise"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare", 
            dpar = "muExpertise"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief",
            dpar = "muExpertise"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "FacilitatorFacilitator2", 
            dpar = "muExpertise"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Homecare", 
            dpar = "muExpertise"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Debrief", 
            dpar = "muExpertise"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Homecare", 
            dpar = "muExpertise"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Debrief", 
            dpar = "muExpertise"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare:FacilitatorFacilitator2", 
            dpar = "muExpertise"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief:FacilitatorFacilitator2", 
            dpar = "muExpertise"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare:FacilitatorFacilitator2", 
            dpar = "muExpertise"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief:FacilitatorFacilitator2", 
            dpar = "muExpertise"),
  
  set_prior("cauchy(0,1)",  
            class = "sd", 
            dpar = "muExpertise"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition", 
            dpar = "muExpertise"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition:Group",
            dpar = "muExpertise"), 
  
  set_prior("normal(0,5)",  
            class = "b",
            coef = "ConditionIntervention", 
            dpar = "muPatient"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare", 
            dpar = "muPatient"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief",
            dpar = "muPatient"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare", 
            dpar = "muPatient"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief",
            dpar = "muPatient"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "FacilitatorFacilitator2", 
            dpar = "muPatient"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Homecare", 
            dpar = "muPatient"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Debrief", 
            dpar = "muPatient"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Homecare", 
            dpar = "muPatient"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Debrief", 
            dpar = "muPatient"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare:FacilitatorFacilitator2", 
            dpar = "muPatient"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief:FacilitatorFacilitator2", 
            dpar = "muPatient"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare:FacilitatorFacilitator2", 
            dpar = "muPatient"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief:FacilitatorFacilitator2", 
            dpar = "muPatient"),
  
  set_prior("cauchy(0,1)",  
            class = "sd", 
            dpar = "muPatient"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition", 
            dpar = "muPatient"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition:Group",
            dpar = "muPatient"),
  
  set_prior("normal(0,5)",  
            class = "b",
            coef = "ConditionIntervention", 
            dpar = "muPatientpsych"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare", 
            dpar = "muPatientpsych"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief",
            dpar = "muPatientpsych"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare", 
            dpar = "muPatientpsych"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief",
            dpar = "muPatientpsych"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "FacilitatorFacilitator2", 
            dpar = "muPatientpsych"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Homecare", 
            dpar = "muPatientpsych"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Debrief", 
            dpar = "muPatientpsych"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Homecare", 
            dpar = "muPatientpsych"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Debrief", 
            dpar = "muPatientpsych"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare:FacilitatorFacilitator2", 
            dpar = "muPatientpsych"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief:FacilitatorFacilitator2", 
            dpar = "muPatientpsych"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare:FacilitatorFacilitator2", 
            dpar = "muPatientpsych"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief:FacilitatorFacilitator2", 
            dpar = "muPatientpsych"),
  
  set_prior("cauchy(0,1)",  
            class = "sd", 
            dpar = "muPatientpsych"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition", 
            dpar = "muPatientpsych"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition:Group",
            dpar = "muPatientpsych"),
  
  set_prior("normal(0,5)",  
            class = "b",
            coef = "ConditionIntervention", 
            dpar = "muRecommendations"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare", 
            dpar = "muRecommendations"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief",
            dpar = "muRecommendations"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare", 
            dpar = "muRecommendations"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief",
            dpar = "muRecommendations"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "FacilitatorFacilitator2", 
            dpar = "muRecommendations"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Homecare", 
            dpar = "muRecommendations"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Debrief", 
            dpar = "muRecommendations"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Homecare", 
            dpar = "muRecommendations"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Debrief", 
            dpar = "muRecommendations"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare:FacilitatorFacilitator2", 
            dpar = "muRecommendations"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief:FacilitatorFacilitator2", 
            dpar = "muRecommendations"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare:FacilitatorFacilitator2", 
            dpar = "muRecommendations"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief:FacilitatorFacilitator2", 
            dpar = "muRecommendations"),
  
  set_prior("cauchy(0,1)",  
            class = "sd", 
            dpar = "muRecommendations"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition", 
            dpar = "muRecommendations"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition:Group",
            dpar = "muRecommendations"),
  
  set_prior("normal(0,5)",  
            class = "b",
            coef = "ConditionIntervention", 
            dpar = "muSDOH"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare", 
            dpar = "muSDOH"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief",
            dpar = "muSDOH"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare", 
            dpar = "muSDOH"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief",
            dpar = "muSDOH"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "FacilitatorFacilitator2", 
            dpar = "muSDOH"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Homecare", 
            dpar = "muSDOH"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeInitial_Debrief", 
            dpar = "muSDOH"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Homecare", 
            dpar = "muSDOH"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "ConditionIntervention:Session_TypeFollowMup_Debrief", 
            dpar = "muSDOH"),
  
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Homecare:FacilitatorFacilitator2", 
            dpar = "muSDOH"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeInitial_Debrief:FacilitatorFacilitator2", 
            dpar = "muSDOH"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Homecare:FacilitatorFacilitator2", 
            dpar = "muSDOH"),
  set_prior("normal(0,5)",  
            class = "b", 
            coef = "Session_TypeFollowMup_Debrief:FacilitatorFacilitator2", 
            dpar = "muSDOH"),
  
  set_prior("cauchy(0,1)",  
            class = "sd", 
            dpar = "muSDOH"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition", 
            dpar = "muSDOH"),
  set_prior("cauchy(0,1)",  
            class = "sd", 
            coef = "Intercept", 
            group = "Condition:Group",
            dpar = "muSDOH")
)


## Model specification
What_complete_Nested_Session_Type_Facil_Mod <-
  brm(
    What_Multi_fmla,
    family = multinomial(),
    prior = what_priors_complete_nested_session_type_facil,
    inits = 0,
    iter = 2000,
    warmup = 1000,
    chains = 2,
    cores = ncores,
    control = list(adapt_delta = 0.9999,
                   max_treedepth = 14)
  ),
data = Data,
family = multinomial(),
prior = what_priors,
inits = 0,
iter = 2000,
warmup = 1000,
chains = 2,
cores = ncores,
control = list(adapt_delta = 0.9999,
               max_treedepth = 14)
)

Start simpler.

Maybe one thing to try is to reduce to bernoulli model (maybe throw away 6 categories, or lump things together or something)

Can also just use a subset of data to start the modeling off and just get the gears rolling. Is there a way to subset the data to simplify the regression? Maybe only use data from 1 facilitator, or lump all 8 control groups together and similarly lump all the intervention groups together?

Could be either

1 Like

Is my understanding correct that the multinomial family in brms uses the Dirichlet distribution for the response?

If that is the case, would a re-parameterization akin to:

parameters {
  simplex[K] phi;
  real<lower=0> kappa;
  simplex[K] theta[N];
  ...
transformed parameters {
  vector[K] alpha = kappa * phi;
  ...
}
model {
  phi ~ ...;
  kappa ~ ...;
  for (n in 1:N)
    theta[n] ~ dirichlet(alpha);

help the situation?

Is this possible through brms’ prior specificaton?

As the name indicates, the multinomial family uses the multinomial distribution as the response distribution. Can you clarify where you think the Dirichlet distribution comes into play? You can also check brms’ stan code via make_stancode.

1 Like

I was just misremembering something I came across when investigating this challenge.

Are there any approaches for re-parameterization that might help reduce the run time of this type of model?

I don’t know to be honest. When writing it in Stan itself, there may be ways to improve its efficiency but I can’t tell you anything specific out of my mind.

Thanks for taking a look.

Although the model is running slowly, it’s reassuring that I’m not doing anything obviously/blatantly incorrect :)

I initially fitted models without nesting the random effects and those ran relatively quickly, but did not correctly reflect the structure of the data.

Thanks for the advice to experiment with simplification. I took a few steps and was able to run a model with only 3 groups in each condition and only 4 response categories. That converged in just over 4.5hrs.

Does that seem reasonable? Is it then also expected that the complete data would take ~40hrs?

And the Rhats and Neffs in the results were all good?

Assuming you’re using the same amount of data and just changing the parameterization, it’s not really clear how things should scale or not. I’d expect more parameters to take longer but not in like a linear way or anything.

To my inexperienced eye, things generally look okay for 5000 iterations with warmup = 3500:

Summary Statistics of Stan-Model

# Fixed effects 

                                                                Parameter Estimate Std.Error       HDI(89%)     pd  ESS Rhat MCSE
                                                    muCaregiver_Intercept    -2.25      0.66 [-3.43, -0.68]  97.5% 1463 1.00 0.03
                                                    muCaregiver_Intercept    -2.25      0.66 [-3.43, -0.68]  97.5% 1463 1.00 0.03
                                                    muCaregiver_Intercept    -2.25      0.66 [-3.43, -0.68]  97.5% 1463 1.00 0.03
                                                    muCaregiver_Intercept    -2.25      0.66 [-3.43, -0.68]  97.5% 1463 1.00 0.03
                                                 muPatientpsych_Intercept    -3.42      0.74 [-4.82, -1.99]  98.7%  741 1.00 0.05
                                                      muCanmeds_Intercept    -0.27      0.77 [-1.83,  1.86]  61.8% 1428 1.00 0.04
                                              muRecommendations_Intercept    -3.51      0.92 [-5.29, -1.77]  99.3% 2002 1.00 0.03
                                        muCaregiver_ConditionIntervention     0.35      0.70 [-0.80,  1.53]  68.9% 3610 1.00 0.01
                                        muCaregiver_ConditionIntervention     0.35      0.70 [-0.80,  1.53]  68.9% 3610 1.00 0.01
                                        muCaregiver_ConditionIntervention     0.35      0.70 [-0.80,  1.53]  68.9% 3610 1.00 0.01
                                        muCaregiver_ConditionIntervention     0.35      0.70 [-0.80,  1.53]  68.9% 3610 1.00 0.01
                                 muCaregiver_Session_TypeInitial_Homecare     0.59      0.37 [ 0.01,  1.22]  94.3% 3111 1.00 0.01
                                 muCaregiver_Session_TypeInitial_Homecare     0.59      0.37 [ 0.01,  1.22]  94.3% 3111 1.00 0.01
                                 muCaregiver_Session_TypeInitial_Homecare     0.59      0.37 [ 0.01,  1.22]  94.3% 3111 1.00 0.01
                                 muCaregiver_Session_TypeInitial_Homecare     0.59      0.37 [ 0.01,  1.22]  94.3% 3111 1.00 0.01
                                  muCaregiver_Session_TypeInitial_Debrief     2.03      0.35 [ 1.49,  2.58] 100.0% 2488 1.00 0.01
                                  muCaregiver_Session_TypeInitial_Debrief     2.03      0.35 [ 1.49,  2.58] 100.0% 2488 1.00 0.01
                                  muCaregiver_Session_TypeInitial_Debrief     2.03      0.35 [ 1.49,  2.58] 100.0% 2488 1.00 0.01
                                  muCaregiver_Session_TypeInitial_Debrief     2.03      0.35 [ 1.49,  2.58] 100.0% 2488 1.00 0.01
                               muCaregiver_Session_TypeFollowMup_Homecare    -0.04      0.46 [-0.75,  0.69]  53.5% 3448 1.00 0.01
                               muCaregiver_Session_TypeFollowMup_Homecare    -0.04      0.46 [-0.75,  0.69]  53.5% 3448 1.00 0.01
                               muCaregiver_Session_TypeFollowMup_Homecare    -0.04      0.46 [-0.75,  0.69]  53.5% 3448 1.00 0.01
                               muCaregiver_Session_TypeFollowMup_Homecare    -0.04      0.46 [-0.75,  0.69]  53.5% 3448 1.00 0.01
                                muCaregiver_Session_TypeFollowMup_Debrief     1.94      0.36 [ 1.36,  2.55] 100.0% 2772 1.00 0.01
                                muCaregiver_Session_TypeFollowMup_Debrief     1.94      0.36 [ 1.36,  2.55] 100.0% 2772 1.00 0.01
                                muCaregiver_Session_TypeFollowMup_Debrief     1.94      0.36 [ 1.36,  2.55] 100.0% 2772 1.00 0.01
                                muCaregiver_Session_TypeFollowMup_Debrief     1.94      0.36 [ 1.36,  2.55] 100.0% 2772 1.00 0.01
                                      muCaregiver_FacilitatorFacilitator2     0.28      0.46 [-0.49,  1.02]  73.2% 3070 1.00 0.01
                                      muCaregiver_FacilitatorFacilitator2     0.28      0.46 [-0.49,  1.02]  73.2% 3070 1.00 0.01
                                      muCaregiver_FacilitatorFacilitator2     0.28      0.46 [-0.49,  1.02]  73.2% 3070 1.00 0.01
                                      muCaregiver_FacilitatorFacilitator2     0.28      0.46 [-0.49,  1.02]  73.2% 3070 1.00 0.01
           muCaregiver_ConditionIntervention.Session_TypeInitial_Homecare    -0.71      0.48 [-1.51,  0.02]  93.2% 3616 1.00 0.01
           muCaregiver_ConditionIntervention.Session_TypeInitial_Homecare    -0.71      0.48 [-1.51,  0.02]  93.2% 3616 1.00 0.01
           muCaregiver_ConditionIntervention.Session_TypeInitial_Homecare    -0.71      0.48 [-1.51,  0.02]  93.2% 3616 1.00 0.01
           muCaregiver_ConditionIntervention.Session_TypeInitial_Homecare    -0.71      0.48 [-1.51,  0.02]  93.2% 3616 1.00 0.01
            muCaregiver_ConditionIntervention.Session_TypeInitial_Debrief     0.04      0.43 [-0.63,  0.66]  53.8% 3106 1.00 0.01
            muCaregiver_ConditionIntervention.Session_TypeInitial_Debrief     0.04      0.43 [-0.63,  0.66]  53.8% 3106 1.00 0.01
            muCaregiver_ConditionIntervention.Session_TypeInitial_Debrief     0.04      0.43 [-0.63,  0.66]  53.8% 3106 1.00 0.01
            muCaregiver_ConditionIntervention.Session_TypeInitial_Debrief     0.04      0.43 [-0.63,  0.66]  53.8% 3106 1.00 0.01
         muCaregiver_ConditionIntervention.Session_TypeFollowMup_Homecare    -1.73      0.68 [-2.86, -0.69]  99.5% 4515 1.00 0.01
         muCaregiver_ConditionIntervention.Session_TypeFollowMup_Homecare    -1.73      0.68 [-2.86, -0.69]  99.5% 4515 1.00 0.01
         muCaregiver_ConditionIntervention.Session_TypeFollowMup_Homecare    -1.73      0.68 [-2.86, -0.69]  99.5% 4515 1.00 0.01
         muCaregiver_ConditionIntervention.Session_TypeFollowMup_Homecare    -1.73      0.68 [-2.86, -0.69]  99.5% 4515 1.00 0.01
          muCaregiver_ConditionIntervention.Session_TypeFollowMup_Debrief    -0.58      0.42 [-1.22,  0.14]  91.5% 3135 1.00 0.01
          muCaregiver_ConditionIntervention.Session_TypeFollowMup_Debrief    -0.58      0.42 [-1.22,  0.14]  91.5% 3135 1.00 0.01
          muCaregiver_ConditionIntervention.Session_TypeFollowMup_Debrief    -0.58      0.42 [-1.22,  0.14]  91.5% 3135 1.00 0.01
          muCaregiver_ConditionIntervention.Session_TypeFollowMup_Debrief    -0.58      0.42 [-1.22,  0.14]  91.5% 3135 1.00 0.01
         muCaregiver_Session_TypeInitial_Homecare.FacilitatorFacilitator2    -0.84      0.51 [-1.62,  0.00]  95.0% 4809 1.00 0.01
         muCaregiver_Session_TypeInitial_Homecare.FacilitatorFacilitator2    -0.84      0.51 [-1.62,  0.00]  95.0% 4809 1.00 0.01
         muCaregiver_Session_TypeInitial_Homecare.FacilitatorFacilitator2    -0.84      0.51 [-1.62,  0.00]  95.0% 4809 1.00 0.01
         muCaregiver_Session_TypeInitial_Homecare.FacilitatorFacilitator2    -0.84      0.51 [-1.62,  0.00]  95.0% 4809 1.00 0.01
          muCaregiver_Session_TypeInitial_Debrief.FacilitatorFacilitator2    -1.40      0.43 [-2.06, -0.64] 100.0% 3254 1.00 0.01
          muCaregiver_Session_TypeInitial_Debrief.FacilitatorFacilitator2    -1.40      0.43 [-2.06, -0.64] 100.0% 3254 1.00 0.01
          muCaregiver_Session_TypeInitial_Debrief.FacilitatorFacilitator2    -1.40      0.43 [-2.06, -0.64] 100.0% 3254 1.00 0.01
          muCaregiver_Session_TypeInitial_Debrief.FacilitatorFacilitator2    -1.40      0.43 [-2.06, -0.64] 100.0% 3254 1.00 0.01
       muCaregiver_Session_TypeFollowMup_Homecare.FacilitatorFacilitator2    -1.05      0.78 [-2.29,  0.15]  92.0% 7604 1.00 0.01
       muCaregiver_Session_TypeFollowMup_Homecare.FacilitatorFacilitator2    -1.05      0.78 [-2.29,  0.15]  92.0% 7604 1.00 0.01
       muCaregiver_Session_TypeFollowMup_Homecare.FacilitatorFacilitator2    -1.05      0.78 [-2.29,  0.15]  92.0% 7604 1.00 0.01
       muCaregiver_Session_TypeFollowMup_Homecare.FacilitatorFacilitator2    -1.05      0.78 [-2.29,  0.15]  92.0% 7604 1.00 0.01
        muCaregiver_Session_TypeFollowMup_Debrief.FacilitatorFacilitator2    -0.97      0.46 [-1.73, -0.29]  98.6% 3684 1.00 0.01
        muCaregiver_Session_TypeFollowMup_Debrief.FacilitatorFacilitator2    -0.97      0.46 [-1.73, -0.29]  98.6% 3684 1.00 0.01
        muCaregiver_Session_TypeFollowMup_Debrief.FacilitatorFacilitator2    -0.97      0.46 [-1.73, -0.29]  98.6% 3684 1.00 0.01
        muCaregiver_Session_TypeFollowMup_Debrief.FacilitatorFacilitator2    -0.97      0.46 [-1.73, -0.29]  98.6% 3684 1.00 0.01
                                     muPatientpsych_ConditionIntervention     0.16      0.70 [-1.06,  1.33]  59.0% 4281 1.00 0.01
                              muPatientpsych_Session_TypeInitial_Homecare    -0.08      0.54 [-1.04,  0.73]  56.2% 3918 1.00 0.01
                               muPatientpsych_Session_TypeInitial_Debrief     1.52      0.50 [ 0.75,  2.29]  99.9% 3666 1.00 0.01
                            muPatientpsych_Session_TypeFollowMup_Homecare     0.05      0.57 [-0.81,  1.01]  53.2% 4828 1.00 0.01
                             muPatientpsych_Session_TypeFollowMup_Debrief     1.69      0.48 [ 0.97,  2.49] 100.0% 4033 1.00 0.01
                                   muPatientpsych_FacilitatorFacilitator2    -0.01      0.54 [-0.92,  0.86]  50.4% 3142 1.00 0.01
        muPatientpsych_ConditionIntervention.Session_TypeInitial_Homecare     0.81      0.62 [-0.15,  1.80]  90.8% 4514 1.00 0.01
         muPatientpsych_ConditionIntervention.Session_TypeInitial_Debrief     0.74      0.55 [-0.12,  1.62]  91.1% 4676 1.00 0.01
      muPatientpsych_ConditionIntervention.Session_TypeFollowMup_Homecare     0.22      0.66 [-0.87,  1.25]  62.4% 5202 1.00 0.01
       muPatientpsych_ConditionIntervention.Session_TypeFollowMup_Debrief    -0.71      0.57 [-1.64,  0.17]  89.8% 4474 1.00 0.01
      muPatientpsych_Session_TypeInitial_Homecare.FacilitatorFacilitator2    -0.16      0.64 [-1.20,  0.83]  60.6% 5325 1.00 0.01
       muPatientpsych_Session_TypeInitial_Debrief.FacilitatorFacilitator2    -0.42      0.54 [-1.24,  0.50]  78.8% 4297 1.00 0.01
    muPatientpsych_Session_TypeFollowMup_Homecare.FacilitatorFacilitator2     1.00      0.64 [-0.03,  1.98]  93.8% 4832 1.00 0.01
     muPatientpsych_Session_TypeFollowMup_Debrief.FacilitatorFacilitator2     0.51      0.55 [-0.39,  1.36]  82.8% 4255 1.00 0.01
                                          muCanmeds_ConditionIntervention     0.84      0.94 [-0.69,  2.09]  79.8% 2898 1.00 0.02
                                   muCanmeds_Session_TypeInitial_Homecare    -2.15      0.39 [-2.75, -1.50] 100.0% 3854 1.00 0.01
                                    muCanmeds_Session_TypeInitial_Debrief    -0.44      0.31 [-0.93,  0.03]  92.7% 3683 1.00 0.01
                                 muCanmeds_Session_TypeFollowMup_Homecare    -1.15      0.35 [-1.72, -0.59] 100.0% 3565 1.00 0.01
                                  muCanmeds_Session_TypeFollowMup_Debrief     0.52      0.29 [ 0.02,  0.95]  95.7% 3075 1.00 0.01
                                        muCanmeds_FacilitatorFacilitator2    -0.31      0.26 [-0.75,  0.11]  87.9% 2494 1.00 0.01
             muCanmeds_ConditionIntervention.Session_TypeInitial_Homecare    -0.76      0.46 [-1.48, -0.05]  95.1% 4509 1.00 0.01
              muCanmeds_ConditionIntervention.Session_TypeInitial_Debrief    -0.77      0.36 [-1.35, -0.22]  98.2% 4258 1.00 0.01
           muCanmeds_ConditionIntervention.Session_TypeFollowMup_Homecare    -2.69      0.54 [-3.50, -1.83] 100.0% 4347 1.00 0.01
            muCanmeds_ConditionIntervention.Session_TypeFollowMup_Debrief    -2.33      0.37 [-2.91, -1.72] 100.0% 3919 1.00 0.01
           muCanmeds_Session_TypeInitial_Homecare.FacilitatorFacilitator2     0.24      0.48 [-0.60,  0.90]  69.2% 4772 1.00 0.01
            muCanmeds_Session_TypeInitial_Debrief.FacilitatorFacilitator2     0.40      0.36 [-0.17,  0.96]  86.7% 3843 1.00 0.01
         muCanmeds_Session_TypeFollowMup_Homecare.FacilitatorFacilitator2     0.72      0.50 [-0.21,  1.46]  90.7% 5622 1.00 0.01
          muCanmeds_Session_TypeFollowMup_Debrief.FacilitatorFacilitator2     0.01      0.38 [-0.63,  0.57]  50.8% 5082 1.00 0.01
                                  muRecommendations_ConditionIntervention     0.05      0.83 [-1.28,  1.39]  52.3% 4286 1.00 0.01
                           muRecommendations_Session_TypeInitial_Homecare    -0.48      0.59 [-1.39,  0.48]  80.6% 4910 1.00 0.01
                            muRecommendations_Session_TypeInitial_Debrief     1.98      0.47 [ 1.28,  2.72] 100.0% 4408 1.00 0.01
                         muRecommendations_Session_TypeFollowMup_Homecare    -1.35      0.72 [-2.48, -0.19]  97.6% 6544 1.00 0.01
                          muRecommendations_Session_TypeFollowMup_Debrief     1.16      0.52 [ 0.38,  2.02]  98.9% 3981 1.00 0.01
                                muRecommendations_FacilitatorFacilitator2    -0.07      0.71 [-1.27,  1.05]  54.2% 3949 1.00 0.01
     muRecommendations_ConditionIntervention.Session_TypeInitial_Homecare    -0.94      0.81 [-2.26,  0.31]  87.8% 6905 1.00 0.01
      muRecommendations_ConditionIntervention.Session_TypeInitial_Debrief     0.76      0.57 [-0.17,  1.64]  91.5% 4357 1.00 0.01
   muRecommendations_ConditionIntervention.Session_TypeFollowMup_Homecare    -0.48      0.89 [-1.91,  0.96]  71.1% 5968 1.00 0.01
    muRecommendations_ConditionIntervention.Session_TypeFollowMup_Debrief     1.07      0.58 [ 0.13,  1.97]  96.3% 4639 1.00 0.01
   muRecommendations_Session_TypeInitial_Homecare.FacilitatorFacilitator2    -0.59      0.82 [-1.99,  0.64]  77.3% 7569 1.00 0.01
    muRecommendations_Session_TypeInitial_Debrief.FacilitatorFacilitator2    -0.58      0.58 [-1.58,  0.28]  84.4% 5212 1.00 0.01
 muRecommendations_Session_TypeFollowMup_Homecare.FacilitatorFacilitator2    -0.28      0.92 [-1.75,  1.09]  62.1% 7484 1.00 0.01
  muRecommendations_Session_TypeFollowMup_Debrief.FacilitatorFacilitator2     1.07      0.57 [ 0.17,  2.00]  97.0% 3695 1.00 0.01


# Random effects 

                                                          Parameter Estimate Std.Error       HDI(89%)     pd  ESS Rhat MCSE
                                              muCaregiver_Intercept    -2.25      0.66 [-3.43, -0.68]  97.5% 1463 1.00 0.03
                                              muCaregiver_Intercept    -2.25      0.66 [-3.43, -0.68]  97.5% 1463 1.00 0.03
                                              muCaregiver_Intercept    -2.25      0.66 [-3.43, -0.68]  97.5% 1463 1.00 0.03
                                              muCaregiver_Intercept    -2.25      0.66 [-3.43, -0.68]  97.5% 1463 1.00 0.03
                                  muCaregiver_ConditionIntervention     0.35      0.70 [-0.80,  1.53]  68.9% 3610 1.00 0.01
                                  muCaregiver_ConditionIntervention     0.35      0.70 [-0.80,  1.53]  68.9% 3610 1.00 0.01
                                  muCaregiver_ConditionIntervention     0.35      0.70 [-0.80,  1.53]  68.9% 3610 1.00 0.01
                                  muCaregiver_ConditionIntervention     0.35      0.70 [-0.80,  1.53]  68.9% 3610 1.00 0.01
                           muCaregiver_Session_TypeInitial_Homecare     0.59      0.37 [ 0.01,  1.22]  94.3% 3111 1.00 0.01
                           muCaregiver_Session_TypeInitial_Homecare     0.59      0.37 [ 0.01,  1.22]  94.3% 3111 1.00 0.01
                           muCaregiver_Session_TypeInitial_Homecare     0.59      0.37 [ 0.01,  1.22]  94.3% 3111 1.00 0.01
                           muCaregiver_Session_TypeInitial_Homecare     0.59      0.37 [ 0.01,  1.22]  94.3% 3111 1.00 0.01
                            muCaregiver_Session_TypeInitial_Debrief     2.03      0.35 [ 1.49,  2.58] 100.0% 2488 1.00 0.01
                            muCaregiver_Session_TypeInitial_Debrief     2.03      0.35 [ 1.49,  2.58] 100.0% 2488 1.00 0.01
                            muCaregiver_Session_TypeInitial_Debrief     2.03      0.35 [ 1.49,  2.58] 100.0% 2488 1.00 0.01
                            muCaregiver_Session_TypeInitial_Debrief     2.03      0.35 [ 1.49,  2.58] 100.0% 2488 1.00 0.01
                         muCaregiver_Session_TypeFollowMup_Homecare    -0.04      0.46 [-0.75,  0.69]  53.5% 3448 1.00 0.01
                         muCaregiver_Session_TypeFollowMup_Homecare    -0.04      0.46 [-0.75,  0.69]  53.5% 3448 1.00 0.01
                         muCaregiver_Session_TypeFollowMup_Homecare    -0.04      0.46 [-0.75,  0.69]  53.5% 3448 1.00 0.01
                         muCaregiver_Session_TypeFollowMup_Homecare    -0.04      0.46 [-0.75,  0.69]  53.5% 3448 1.00 0.01
                          muCaregiver_Session_TypeFollowMup_Debrief     1.94      0.36 [ 1.36,  2.55] 100.0% 2772 1.00 0.01
                          muCaregiver_Session_TypeFollowMup_Debrief     1.94      0.36 [ 1.36,  2.55] 100.0% 2772 1.00 0.01
                          muCaregiver_Session_TypeFollowMup_Debrief     1.94      0.36 [ 1.36,  2.55] 100.0% 2772 1.00 0.01
                          muCaregiver_Session_TypeFollowMup_Debrief     1.94      0.36 [ 1.36,  2.55] 100.0% 2772 1.00 0.01
                                muCaregiver_FacilitatorFacilitator2     0.28      0.46 [-0.49,  1.02]  73.2% 3070 1.00 0.01
                                muCaregiver_FacilitatorFacilitator2     0.28      0.46 [-0.49,  1.02]  73.2% 3070 1.00 0.01
                                muCaregiver_FacilitatorFacilitator2     0.28      0.46 [-0.49,  1.02]  73.2% 3070 1.00 0.01
                                muCaregiver_FacilitatorFacilitator2     0.28      0.46 [-0.49,  1.02]  73.2% 3070 1.00 0.01
     muCaregiver_ConditionIntervention.Session_TypeInitial_Homecare    -0.71      0.48 [-1.51,  0.02]  93.2% 3616 1.00 0.01
     muCaregiver_ConditionIntervention.Session_TypeInitial_Homecare    -0.71      0.48 [-1.51,  0.02]  93.2% 3616 1.00 0.01
     muCaregiver_ConditionIntervention.Session_TypeInitial_Homecare    -0.71      0.48 [-1.51,  0.02]  93.2% 3616 1.00 0.01
     muCaregiver_ConditionIntervention.Session_TypeInitial_Homecare    -0.71      0.48 [-1.51,  0.02]  93.2% 3616 1.00 0.01
      muCaregiver_ConditionIntervention.Session_TypeInitial_Debrief     0.04      0.43 [-0.63,  0.66]  53.8% 3106 1.00 0.01
      muCaregiver_ConditionIntervention.Session_TypeInitial_Debrief     0.04      0.43 [-0.63,  0.66]  53.8% 3106 1.00 0.01
      muCaregiver_ConditionIntervention.Session_TypeInitial_Debrief     0.04      0.43 [-0.63,  0.66]  53.8% 3106 1.00 0.01
      muCaregiver_ConditionIntervention.Session_TypeInitial_Debrief     0.04      0.43 [-0.63,  0.66]  53.8% 3106 1.00 0.01
   muCaregiver_ConditionIntervention.Session_TypeFollowMup_Homecare    -1.73      0.68 [-2.86, -0.69]  99.5% 4515 1.00 0.01
   muCaregiver_ConditionIntervention.Session_TypeFollowMup_Homecare    -1.73      0.68 [-2.86, -0.69]  99.5% 4515 1.00 0.01
   muCaregiver_ConditionIntervention.Session_TypeFollowMup_Homecare    -1.73      0.68 [-2.86, -0.69]  99.5% 4515 1.00 0.01
   muCaregiver_ConditionIntervention.Session_TypeFollowMup_Homecare    -1.73      0.68 [-2.86, -0.69]  99.5% 4515 1.00 0.01
    muCaregiver_ConditionIntervention.Session_TypeFollowMup_Debrief    -0.58      0.42 [-1.22,  0.14]  91.5% 3135 1.00 0.01
    muCaregiver_ConditionIntervention.Session_TypeFollowMup_Debrief    -0.58      0.42 [-1.22,  0.14]  91.5% 3135 1.00 0.01
    muCaregiver_ConditionIntervention.Session_TypeFollowMup_Debrief    -0.58      0.42 [-1.22,  0.14]  91.5% 3135 1.00 0.01
    muCaregiver_ConditionIntervention.Session_TypeFollowMup_Debrief    -0.58      0.42 [-1.22,  0.14]  91.5% 3135 1.00 0.01
   muCaregiver_Session_TypeInitial_Homecare.FacilitatorFacilitator2    -0.84      0.51 [-1.62,  0.00]  95.0% 4809 1.00 0.01
   muCaregiver_Session_TypeInitial_Homecare.FacilitatorFacilitator2    -0.84      0.51 [-1.62,  0.00]  95.0% 4809 1.00 0.01
   muCaregiver_Session_TypeInitial_Homecare.FacilitatorFacilitator2    -0.84      0.51 [-1.62,  0.00]  95.0% 4809 1.00 0.01
   muCaregiver_Session_TypeInitial_Homecare.FacilitatorFacilitator2    -0.84      0.51 [-1.62,  0.00]  95.0% 4809 1.00 0.01
    muCaregiver_Session_TypeInitial_Debrief.FacilitatorFacilitator2    -1.40      0.43 [-2.06, -0.64] 100.0% 3254 1.00 0.01
    muCaregiver_Session_TypeInitial_Debrief.FacilitatorFacilitator2    -1.40      0.43 [-2.06, -0.64] 100.0% 3254 1.00 0.01
    muCaregiver_Session_TypeInitial_Debrief.FacilitatorFacilitator2    -1.40      0.43 [-2.06, -0.64] 100.0% 3254 1.00 0.01
    muCaregiver_Session_TypeInitial_Debrief.FacilitatorFacilitator2    -1.40      0.43 [-2.06, -0.64] 100.0% 3254 1.00 0.01
 muCaregiver_Session_TypeFollowMup_Homecare.FacilitatorFacilitator2    -1.05      0.78 [-2.29,  0.15]  92.0% 7604 1.00 0.01
 muCaregiver_Session_TypeFollowMup_Homecare.FacilitatorFacilitator2    -1.05      0.78 [-2.29,  0.15]  92.0% 7604 1.00 0.01
 muCaregiver_Session_TypeFollowMup_Homecare.FacilitatorFacilitator2    -1.05      0.78 [-2.29,  0.15]  92.0% 7604 1.00 0.01
 muCaregiver_Session_TypeFollowMup_Homecare.FacilitatorFacilitator2    -1.05      0.78 [-2.29,  0.15]  92.0% 7604 1.00 0.01
  muCaregiver_Session_TypeFollowMup_Debrief.FacilitatorFacilitator2    -0.97      0.46 [-1.73, -0.29]  98.6% 3684 1.00 0.01
  muCaregiver_Session_TypeFollowMup_Debrief.FacilitatorFacilitator2    -0.97      0.46 [-1.73, -0.29]  98.6% 3684 1.00 0.01
  muCaregiver_Session_TypeFollowMup_Debrief.FacilitatorFacilitator2    -0.97      0.46 [-1.73, -0.29]  98.6% 3684 1.00 0.01
  muCaregiver_Session_TypeFollowMup_Debrief.FacilitatorFacilitator2    -0.97      0.46 [-1.73, -0.29]  98.6% 3684 1.00 0.01


# Random effects Intercept: Condition__muCanmeds

                         Parameter Estimate Std.Error       HDI(89%)    pd  ESS Rhat MCSE
      Condition__muCanmeds.Control    -0.28      0.70 [-2.45,  1.30] 68.8% 1484 1.00 0.02
 Condition__muCanmeds.Intervention     0.28      0.67 [-1.20,  2.39] 68.6% 1486 1.00 0.03


# Random effects Intercept: Condition__muCaregiver

                           Parameter Estimate Std.Error       HDI(89%)    pd  ESS Rhat MCSE
      Condition__muCaregiver.Control    -0.03      0.44 [-1.44,  1.16] 56.1% 1313 1.00 0.02
 Condition__muCaregiver.Intervention     0.04      0.46 [-1.07,  1.48] 57.2% 1315 1.00 0.02


# Random effects Intercept: Condition__muPatientpsych

                              Parameter Estimate Std.Error       HDI(89%)    pd ESS Rhat MCSE
      Condition__muPatientpsych.Control    -0.02      0.42 [-1.36,  1.21] 53.2% 682 1.00 0.02
 Condition__muPatientpsych.Intervention     0.01      0.42 [-1.25,  1.37] 52.3% 698 1.00 0.03


# Random effects Intercept: Condition__muRecommendations

                                 Parameter Estimate Std.Error       HDI(89%)    pd  ESS Rhat MCSE
      Condition__muRecommendations.Control    -0.00      0.45 [-1.19,  1.48] 50.8% 1576 1.00 0.02
 Condition__muRecommendations.Intervention     0.00      0.44 [-1.44,  1.23] 50.3% 1423 1.00 0.02


# Random effects Intercept: Condition Group__muCanmeds

                                  Parameter Estimate Std.Error       HDI(89%)    pd  ESS Rhat MCSE
      Condition.Group__muCanmeds.Control_12    -0.03      0.10 [-0.35,  0.16] 66.2% 3027 1.00 0.01
      Condition.Group__muCanmeds.Control_20     0.02      0.10 [-0.17,  0.33] 62.4% 3446 1.00 0.00
       Condition.Group__muCanmeds.Control_6    -0.00      0.10 [-0.32,  0.25] 53.5% 3966 1.00 0.00
  Condition.Group__muCanmeds.Intervention_1    -0.00      0.09 [-0.25,  0.25] 51.0% 3948 1.00 0.00
 Condition.Group__muCanmeds.Intervention_13     0.01      0.10 [-0.20,  0.29] 56.4% 3607 1.00 0.00
 Condition.Group__muCanmeds.Intervention_19    -0.00      0.10 [-0.30,  0.26] 50.2% 3247 1.00 0.00


# Random effects Intercept: Condition Group__muCaregiver

                                    Parameter Estimate Std.Error       HDI(89%)    pd  ESS Rhat MCSE
      Condition.Group__muCaregiver.Control_12     0.01      0.28 [-0.52,  0.53] 51.1% 3555 1.00 0.01
      Condition.Group__muCaregiver.Control_20     0.16      0.28 [-0.36,  0.73] 73.3% 3417 1.00 0.01
       Condition.Group__muCaregiver.Control_6    -0.19      0.35 [-0.89,  0.45] 74.0% 3329 1.00 0.01
  Condition.Group__muCaregiver.Intervention_1    -0.32      0.33 [-0.95,  0.18] 85.5% 3637 1.00 0.01
 Condition.Group__muCaregiver.Intervention_13     0.08      0.28 [-0.45,  0.65] 62.4% 3862 1.00 0.01
 Condition.Group__muCaregiver.Intervention_19     0.25      0.35 [-0.28,  1.05] 80.2% 3163 1.00 0.01


# Random effects Intercept: Condition Group__muPatientpsych

                                       Parameter Estimate Std.Error       HDI(89%)    pd  ESS Rhat MCSE
      Condition.Group__muPatientpsych.Control_12     0.02      0.29 [-0.60,  0.66] 53.6% 3589 1.00 0.01
      Condition.Group__muPatientpsych.Control_20    -0.24      0.37 [-1.02,  0.31] 78.6% 2957 1.00 0.01
       Condition.Group__muPatientpsych.Control_6     0.15      0.34 [-0.48,  0.94] 70.6% 3131 1.00 0.01
  Condition.Group__muPatientpsych.Intervention_1     0.23      0.34 [-0.24,  1.00] 78.9% 3086 1.00 0.01
 Condition.Group__muPatientpsych.Intervention_13    -0.01      0.28 [-0.65,  0.56] 52.3% 3548 1.00 0.01
 Condition.Group__muPatientpsych.Intervention_19    -0.17      0.34 [-0.99,  0.43] 70.5% 2993 1.00 0.01


# Random effects Intercept: Condition Group__muRecommendations

                                          Parameter Estimate Std.Error       HDI(89%)    pd  ESS Rhat MCSE
      Condition.Group__muRecommendations.Control_12    -1.11      0.75 [-2.61, -0.01] 95.4% 3029 1.00 0.02
      Condition.Group__muRecommendations.Control_20     0.69      0.64 [-0.28,  1.89] 88.6% 3044 1.00 0.01
       Condition.Group__muRecommendations.Control_6     0.35      0.68 [-0.93,  1.50] 70.0% 3105 1.00 0.01
  Condition.Group__muRecommendations.Intervention_1    -0.03      0.59 [-1.08,  1.06] 52.5% 3205 1.00 0.01
 Condition.Group__muRecommendations.Intervention_13     0.44      0.60 [-0.66,  1.48] 77.8% 3022 1.00 0.01
 Condition.Group__muRecommendations.Intervention_19    -0.34      0.67 [-1.50,  0.94] 70.7% 3311 1.00 0.01


# Random effects SD/Cor

                             Parameter Estimate Std.Error       HDI(89%)     pd  ESS Rhat MCSE
       Condition_muCaregiver_Intercept     0.60      0.58 [ 0.00,  1.87] 100.0% 1719 1.00 0.02
 Condition.Group_muCaregiver_Intercept     0.42      0.23 [ 0.05,  0.84] 100.0% 1564 1.00 0.01

Just chiming into say that I also had speed issues with multinomial models with random effects a while back. It wasn’t clear to me if this was the folk-theorem in action or something else and I didn’t have time to investigate. If I have some time later I may code up a simple example and see if brms can recover parameters for something like a random-intercepts multinomial model.

Oh, sorry for not responding. Maybe run shorter chains? And it’s unlikely you need 3500 warmup draws.

What happens if you just go 500 warmups and 1000 post warmup draws?

I found that with less warmup I had a lot of divergent transitions after warmup and with shorter chains I had low ESS’s

Well I guess I can’t argue with that.

I guess the next thing I’d point to are:

control = list(adapt_delta = 0.9999,
               max_treedepth = 14)

Like there must be some weird geometry in this problem to need adapt_delta that high and treedepth that high. This is gonna make the timestep crazy-small.

It seems weird that so many of these groups of four are like exactly the same number:

muCaregiver_Intercept    -2.25      0.66 [-3.43, -0.68]  97.5% 1463 1.00 0.03
muCaregiver_Intercept    -2.25      0.66 [-3.43, -0.68]  97.5% 1463 1.00 0.03
muCaregiver_Intercept    -2.25      0.66 [-3.43, -0.68]  97.5% 1463 1.00 0.03
muCaregiver_Intercept    -2.25      0.66 [-3.43, -0.68]  97.5% 1463 1.00 0.03

Is that just an artifact of the tables? Or are there groups of fours where things are turning out exactly the same? Seems weird to have this many numbers line up in an MCMC thing, even if they were repeats of the same estimate.