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)

First, I tried the following model:

fit1=brm(y~t2(x1,by=x2),data=dat,chains=1,iter=200)

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)

The third model is:

fit3=brm(y~t2(x1,x2),data=dat,chains=1,iter=200)

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!