How do I mathematically specify this GAM model? I need help figuring out how to describe a GAM with random effects I estimated using mgcv for a journal publication.
An equivalent (reproducible) model is:
library(mgcv)

df <- as.data.frame(mtcars) 
f <- as.formula(mpg ~ 1 + carb + s(hp, k = 7) + s(hp, carb, bs = "re"))
fit <- gam(formula = f, data = df)
summary(fit)



Family: gaussian 
Link function: identity 

Formula:
mpg ~ 1 + s(hp, k = 7) + carb + s(hp, carb, bs = "re")

Parametric coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  20.4092     1.6512  12.360 9.83e-13 ***
carb         -0.1133     0.5525  -0.205    0.839    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Approximate significance of smooth terms:
                 edf Ref.df     F  p-value    
s(hp)      2.540e+00  3.156 15.31 5.17e-06 ***
s(hp,carb) 1.156e-09  1.000  0.00   0.0932 .  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

R-sq.(adj) =  0.726   Deviance explained = 75.7%
GCV = 11.618  Scale est. = 9.9692    n = 32

My best attempt is the following:
$$
\begin{align}
mpg_{i} &= \beta_0 + + \beta_{1}(carb_i) + f_1(hp_i) + f_{1[j]}(hp_i, \ carb_j) + \epsilon_i \\
f_{1[j]} &\sim f_1 b_{1[j]}(carb_j) \\
b_{1[j]} &\sim N(0, \ \sigma^2_{carb}) \\
\epsilon_i &\sim N(0, \ \sigma^2_\epsilon)
\end{align}
$$
Does this correctly indicate the multilevel nature of the model? (i.e., the random slope associated with carb)
Thanks in advance as I find it much easier to use these models than describe them (which is probably something I need to fix!)

Yes, you are right, if carb was a factor, you would get a new slope for every level of the factor. And since the field carb contains only finitely many values, I was not sure why you used it in the example. And yes, you are also right that, if those are continuous fields, you will get a single slope for the interaction term which is simply the product of, in the example, hp and carb. But with just one term, there is no point in applying random effects. The idea of random effects is to create some connection between fitted values, e.g. you might want several factor level dependent offsets to be rather close to each other ("shrink" towards each other, "shrinkage effect"). But if there is only one fitted value, there cannot be any shrinking.
