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:

set.seed(10)
dat <- gamSim(3,n=400)
head(dat)
image

First, I tried the following model:
fit1=brm(y~t2(x1,by=x2),data=dat,chains=1,iter=200)
image
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:
fit2=brm(y~s(x1,x2),data=dat,chains=1,iter=200)
image

The third model is:
fit3=brm(y~t2(x1,x2),data=dat,chains=1,iter=200)
image

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:


or

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.

Sorry to resurrect an old topic, but I’ve also been a bit insecure about the interpretation of the coefficients of the smooth terms. I’ve read the available documentation, but would like some clarification. I know that a significant smooth term in the frequentist context indicates that the shape is different from flat, and therefore a real smooth effect, but does the inclusion of 0 in the posterior interval of a smooth term have the same interpretation? I’ve recently been advised not to attempt to interpret the estimated coefficients at all, and to simply describe the conditional_smooths, but this also seems unsatisfying.

I also would appreciate some clarification as to the distinction between t2x1x2_1, t2x1x2_2, t2x1x2_3 as per the original question. Do people share the opinion of my colleague that those are uninterpretable?

Regarding interpretation of the coefficients - I don’t think that they are very interpretable. See here, especially the link to Tristan Mahr’s article that I link in my first response to my own question.

2 Likes