Hierarchical Logistic Regression. How to reparameterize?

You could try to fit this model using Bambi.

The non-hierarchical version

model = bmb.Model(
  "CONV_FLAG ~ EXP_FLAG + NETWORK_IDX", 
  data_tv_s,
  family="bernoulli"
)
idata = model.fit()

The hierarchical version (i.e. varying intercept and varying slopes)

model = bmb.Model(
  "CONV_FLAG ~ EXP_FLAG + NETWORK_IDX + (EXP_FLAG|NETWORK_IDX)", 
  data_tv_s,
  family="bernoulli"
)
idata = model.fit()

It can also be good to select a sub-sample of the data in the first attempts to fit the model to detect possible improvements faster.

1 Like