Options to circumvent need for ti() tensors

Hello,

I’ve not included reproducible code here because my question is largely about practical application in brms, and not about model diagnostics or errors per se.

I am currently using brms to model individual-level responses to a binary and ordered stimulus across time where the response is measured continuously. However, the degree to which the population (not the individuals) respond to the stimulus is probably modulated by an environmental parameter (for the sake of this example, we will say light exposure in lux). In mgcv, this problem is approached by using a ti() tensor, for example:

mod = bam(Response ~ Stimulus + s(Time, k = 4, bs = "cr") + 
 s(Time, by = Simulus, k = 4, bs = "cr", m = 1) + 
 s(Lux, k = 8, bs = "tp") + 
 ti(Time, Lux, Stimulus, k = (4,8), bs = ("cr", "tp", "fs")) + 
 s(Time, Individual_ID, by = Stimulus, bs = "re"), 
 data = Data, 
 method = "REML"))

wherein ti() ensures that concurvity between splines and the sole tensor are low (I’m also ignoring autocorrelation here and am assuming that individual differences are generalisable by linear slopes). In brms, I understand that ti() tensors are not available, yet replacing ti() with t2() should result in ugly concurvity issues (regardless of how penalisation is partitioned). So, In practice, I understand that I could remodel the above example as:

mod = bam(Response ~ Stimulus + 
 t2(Time, Lux, k = c(4, 8), bs = c("cr", "tp"), full = TRUE) + 
 t2(Time, Lux, by = Stimulus, k = c(4, 8), bs = c("cr", "tp"), m = 1) + 
 s(Time, Individual_ID, by = Stimulus, bs = "re"), 
 data = Data, 
 method = "REML"))

which is not identical, but cleaner and would be accepted in brms with reduced risk of concurvity. I am, however, highly skeptical of modelling random slopes for individuals if the main effect of the parameter across which individuals vary is not included. Am I correct in this skepticism? If so, would anyone have suggestions as to how concurvity issues could be circumvented without need for a ti() tensor?

Thanks

1 Like

I’ll try to rephrase this into questions about what t2() is doing behind the scenes, and how integration with random slopes is (perhaps) conducted. In mgcv, I gather that t2() estimates basis functions for each parameter loaded into the tensor (marginal terms), along with basis functions for the interaction between both marginal terms (i.e. f(a) + f(b) + f(a,b)). This seems clear when breaking down the “smooth” element of t2() tensor constructed in an mgcv model:

model = gam(Y ~ t2(a, b,  k = c(8, 4), bs = c("cr", "tp")), 
  data = data)
model$smooth[[1]]$margin

where “1” corresponds to the first smooth function in an mgcv model “model” that was constructed using t2(). In this way, I suspect that t2() behaves similarly to te(), and both should yield similar (see disclaimer below) results to a model with marginal terms separated and loaded using ti(), i.e.:

model = gam(Y ~ ti(a, k = 8, bs = "cr") + ti(b, k = 4, bs = "tp") + 
  ti(a, b, bs = c("cr", "tp"), k = c(8,4)), data = data)

Whilst outputs might be similar between the two above models (and one constructed with te() instead of t2()), they will not be the same owing to differences in penalisation that I won’t describe here (Eric Pedersen and Gavin Simpson [#ucfagls] do so nicely in their PeerJ review).

My questions, then, are:

  1. Does t2() in brms partition functional estimates (that is, basis functional estimates) for marginal terms and the interaction of both?

  2. Is my understanding of how t2() simply flawed, such that basis functions for marginal terms are not estimated independently at all (of course, acknowledging that f(a,b) still exists)?

  3. If basis functions are estimated for marginal terms independently as part of t2() functionality, can random slopes be estimated for one marginal term alone?

1 Like

I am not an expert in tensor splines so this question is perhaps better asked to Simon Wood or some of his people. Since brms uses mgcv under the hood, t2 splines in brms have the same properties (up to some hyperpriors we can ignore here) as the t2 spline in mgcv (as you know).

Perhaps the only difficulty is that brms does not use the standard “penalized spline” parameterization but the “random effects” parameterization as does gamm::gamm and gamm4::gamm4 (with different engine in the background). I don’t know how the reparameterization affects the relation between marginal and interactional parts of the spline and you will need to either consult the primary literature for this (which you may have done already) or ask Simon for advice.

I am sorry that I cannot give you a more helpful answer.

1 Like

HI Paul,

Thanks for the response and thoughts - much appreciated. It’s an interesting point about splines being parameterised as random effects - I hadn’t thought carefully enough about how this might influence the splitting of basis function estimation. I’ll try reaching out to Simon and will relay his thoughts here.

Josh

2 Likes