Binomial hierarchical gam

I’d like to predict a binomial output as a smooth interaction between two continuous variables that vary by a group term. Something like:

brm(y ~ t2(x1, x2) + (1 | group), data, family = binomial)

What is the proper way to specify this model in brms?

Shell the smooth term vary by the levels of group as well? If not, your model seems reasonable. Else, you could try something like

brm(y ~ t2(x1, x2, by = group) + (1 | group), data, family = binomial)

Please make sure, group is a factor or otherwise mgcv might throw confusing warnings.

Thanks for the reply - I intended to allow the smooths to vary by group, so I used your formulation. Good to know both ways though. Not to hijack my own thread here, but are you aware of any non-Bayesian implementations of hierarchical gams? The stan version is great, but the HMC just doesn’t scale very well for larger data sets.

If you mean by “doesn’t scale very well” that MCMC algorithms take more time than maximum likelihood estimation, you are right. That’s the price you have to pay for full Bayesian inference. ;-)

You may try out gamm4::gamm for hierachical gams in a frequentist framework.