3
$\begingroup$

I am working with data on cuteness judgements and size judgments for differently named fantasy creatures. The interesting part of the different names are the vowels contained in them.

The question I am fitting a GAM for is: Do the effects of cuteness and vowel interact when it comes to size judgements?

Thus far, my model looks like this:

mdl1 <- gam(size ~ 
                s(cuteness, bs = "bs", by = vowel, k = 5),
                data = data)

The interaction of cuteness and vowel reaches significance for some of the vowels (which is fine).

Now a reviewer asked to modify the model so that not only the interaction effects of cuteness and vowel are contained but also the individual main effects of both cuteness and vowel, e.g. like this:

mdl2 <- gam(size ~ 
                s(cuteness, bs = "bs", by = vowel, k = 5) +
                cuteness +
                vowel,
                data = data)

As I have not worked with interactions in GAMs before, I am at a loss when it comes to deciding whether such a model structure is valid / makes sense (from a statistical point of view). Hence, my question: Is such a model structure valid, does it make sense?

$\endgroup$

1 Answer 1

2
$\begingroup$

Your original model was incorrectly specified; it should have been

mdl1 <- gam(size ~ vowel +
                s(cuteness, bs = "bs", by = vowel, k = 5),
                data = data, method = "REML", family = ...)

Where beyond some technical things — method and choosing an appropriate family for size (is it really conditionally Gaussian? 0 or negative size values don't make immediate sense to me and if so that might preclude using family = gaussian()) — note that I have included the mean response for each vowel through the parametric factor term. You could replace this with s(vowel, bs = "re") instead.

With that specification you have the main effect for the vowel means but there is no average effect for cuteness, which is what I presume the reviewer means by "main effect". To specify that model, I would suggest using the new-ish "sz" basis:

mdl1 <- gam(size ~
                s(cuteness, bs = "bs", k = 5) +
                s(cuteness, vowel, bs = "sz", k = 5,
                  xt = list(bs = "bs")),
                data = data, method = "REML", family = ...)

With this basis, you don't need the explicit parametric term for the group means; those are included in the "sz" basis, as deviations from the overall mean of the response (the model constant / Intercept term).

$\endgroup$
2
  • $\begingroup$ Thank you so much! Is there a way to check for which vowels the interaction of cuteness and vowel reaches significance? The interaction overall clearly reaches significance (p<2e-16 for s(cuteness,vowel)). $\endgroup$
    – odaxom
    Commented Sep 9, 2023 at 11:23
  • 1
    $\begingroup$ I think you'd need to do this with post-hoc tests, just like you would for a linear model - you need to predict from the model or combine terms as you want to test for contrasts involving the two smooths. The general idea is in gratia::difference_smooths() for example, but it doesn't know yet how to work with these sz basis smooths where we want the "main" effect smooth plus pairs of smooths created by sz. The general idea is also discussed here: fromthebottomoftheheap.net/2017/10/10/difference-splines-i but only for factor by smooths; the math is the same however $\endgroup$ Commented Sep 11, 2023 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.