GAM using brm

Hi there, I am trying to study GAM with brm. In doing some examples, there are two things hard for to understand.

The data I used as examples:

dat <- gamSim(3,n=400)

First, I tried the following model:
The question: there is only one smooth term “sds(t2x1x2_1)”, but why is there two interaction terms of smooth x1 and numeric x2 in population-level effects? what do those two terms represent?

The second model is:

The third model is:

Question: as far as I understand, both s(x1, x2) and t2(x1, x2) express the statistical model: y = f(x1) + f(x2) + f(x1, x2) + error. In the population-level effects, why are there two terms (sx1x2_1 and sx1x2_2) besides intercept in the second model while three terms (t2x1x2_1, t2x1x2_2, t2x1x2_3) in the third model?

Many thanks!

I’m sure @paul.buerkner can clarify further, but I’d note here that smooths in brms are implemented through mgcv. Accordingly, I’d recommend taking a look at articles like this:


to get a sense of the difference between a two-dimensional s() vs t2() smooth. Graphic pp_checks and conditional_smooths will tell you more what’s happening than trying to interpret the coefficients specifically.

1 Like

Many thanks! @franzsf. I will go through the materials you kindly provided.