2

I'm using the gam.vcomp() function to obtain the variance explained by each predictor in various GAMs fitted using the mgcv package in R.

Gam1 <- gam(presence = s(var1, k=10) + s(var2, k=10) + s(var3, k=10) + var4,
            family=binomial))  

Gam2 <- gam(presence = s(var1, k=10) + s(var2, var3, k=100) + var4, family= binomial))

The variance components returned by gam.vcomp() are something like this:

  • Gam1: s(var1)= 17, s(var2) = 14, s(var3) = 900
  • Gam2: s(var1)= 16, s(var2,3)= 15

The results for the Gam1 seem plausible as I know that var3 is the most important one. I also know the var2,var3 interaction exists, but am not sure of its importance. The plots of the marginals suggest that the s(var2, var3) interaction in model 2 does indeed capture the behaviour of both s(var2) and s(var3) from model 1, and that the importance of the interaction is sizable.

I am therefore unable to explain why the variance component for the s(var2, var3) term is that low, much lower than the s(var3) itself. Is there a plausible explanation for this? Am I missing something obvious?

Gavin Simpson
  • 37,567
  • 5
  • 110
  • 153

1 Answers1

1

I think what's going on is:

In Gam2, the statement s(var2, var3, k=100) is telling the model to use a single penalty term for var2 and var3, while in Gam1, the model is using a penalty term for each variable. If the variables aren't on similar scales (e.g. var1 is temperature, var2 is elevation), this could artificially constrain the variance component for s(var2,var3).

If you want to test for a main effect plus a continuous-continuous interaction, I would suggest using ti(var2,var3) or te(var2,var3) instead of s(var2,var3) (here's a post on the difference between ti and te). Your modified model would look like:

    Gam3 <- gam(presence = s(var1) + s(var2) + s(var3) + var4, #Similar to Gam1
          ti(var2,var3), #Tensor product smoother (interaction) between var2 & var3
          family= binomial))
    gam.vcomp(Gam3) #Returns variance components of var1-3, plus var2:3 interaction
S. Robinson
  • 153
  • 10