2
$\begingroup$

I'm seeking a good reference to explain the gam model output to colleague. Here is my model.

mod1 <- gam(severity ~  s(mean_rh, k = 8) + s(mean_temp, k = 10) + s(mean_ws, k =7) + s(avg_daily_rain, k = 7), family = betar(),  data = dat_seasonal)

summary(mod1)

Here is the output:

Formula:
disease_severity ~ s(mean_rh, k = 8) + s(mean_temp, k = 10) + 
    s(mean_ws, k = 7) + s(avg_daily_rain, k = 7)

Parametric coefficients:
            Estimate Std. Error z value Pr(>|z|)
(Intercept)  -0.1687     0.1374  -1.228    0.219

Approximate significance of smooth terms:
                    edf Ref.df Chi.sq  p-value    
s(mean_rh)        1.000  1.000   2.76 0.096633 .  
s(mean_temp)      4.231  4.598  74.22  < 2e-16 ***
s(mean_ws)        2.461  2.673  17.53 0.000669 ***
s(avg_daily_rain) 1.000  1.000  49.89  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

R-sq.(adj) =  0.847   Deviance explained = 91.8%
-REML = -29.205  Scale est. = 1         n = 37

Here is the raw data plot (left) and the model output plot (right) for the predictor mean_temp.

enter image description here

My collaborator is not aware of GAMS and expects linear/continuous/higher disease severity with increasing temperatures OR a bell shaped curve (he doesn't expect less disease at 14 & 16 degree Celsius and higher disease at 12 degree Celcius). Here is his specific comment. "Does the figure show greater disease severity at 11 and 17 degree Celsius than the temperature in between? That is what I saw in this subfigure and that is against current knowledge and indefensible." I need to explain to him with a reference that the model has captured the raw data pattern very well, and the whole point behind a GAM is that it models complex behavior between predictors and outcomes. Terms with EDFs higher than one are not supposed to have a singular explanation. The response variable is not linear, DHARMa residuals are fine and the gam.check() output is also good. Thanks

$\endgroup$
0

2 Answers 2

1
$\begingroup$

An Introduction to Statistical Learning covers the principles of GAMs in Section 7.7, with Section 7.7.1 specifically on regression models like yours. I don't think that the particular smooths described there are identical to the s() smooths in the gam() function of mgcv that you used, but the general principle of smooth nonlinear additive modeling is the same.

Note that comparison to the raw data plot can be misleading, as it doesn't take into account the other predictor variables. I'll admit that I didn't at first see how the curve on the right could reasonably have represented the raw data on the left, until I remembered what I was looking at.

As mean_rh and avg_daily_rain ended up with what seem to be linear fits, you might display the residuals around what you would have predicted based on those linear fits, instead of showing raw data values. That might make the curvilinear association with mean_temp more obvious.

$\endgroup$
6
  • $\begingroup$ I have already added residuals using plot(mod1, rug = TRUE, residuals = TRUE, pch = 1, cex = 1, shade = TRUE, seWithMean = TRUE, shift = coef(mod1)[1]). Unless you're referring to some other residuals? $\endgroup$
    – Ahsk
    Commented Feb 16, 2023 at 1:08
  • $\begingroup$ @Ahsk I'm looking for a way to generate something like a "raw data" plot that looks more like your smooth. The raw data plot you show doesn't take into account any of the other variables in the model. If you could take into account the contributions of mean_rh and avg_daily_rain, that might help. Try plotting the residuals from a simple linear model, with just those two linear predictors, against the mean_temp values as an alternative to your simple raw data plot on the left. I suspect that will look more like the smooth on the right. $\endgroup$
    – EdM
    Commented Feb 16, 2023 at 14:35
  • $\begingroup$ Okay, thank you. $\endgroup$
    – Ahsk
    Commented Feb 18, 2023 at 1:33
  • $\begingroup$ In addition to providing the reference, maybe I should reword my interpretation too to avoid potential conflict. Can I say that, Overall, increasing temperatures had a positive effect on the response variable, although the effect was not linear. Lower values for response variable were observed between 14-16 degree Celsius. Thanks very much. $\endgroup$
    – Ahsk
    Commented Feb 19, 2023 at 11:53
  • $\begingroup$ @Ahsk that doesn't seem to describe the modeled values on the plot on the right, although it might describe the raw values on the left. Modeled values at 12 degrees are about the same as they are at 17. If you are talking about the modeled values, I also wouldn't describe them as "observed." For the modeled values you might say something like: "With other variables taken into account, the model suggests a dip in the response as a function of temperature between about 14 and 16 degrees." $\endgroup$
    – EdM
    Commented Feb 19, 2023 at 15:16
2
$\begingroup$

You could cite the famous book Generalized Additive Models, An introduction with R. It include a lot of explanations and several examples.

$\endgroup$
2
  • $\begingroup$ Thanks. The book is not available for free. I'm looking for link to somewhat similar example, which is readily available. $\endgroup$
    – Ahsk
    Commented Feb 15, 2023 at 14:45
  • $\begingroup$ I am sorry. Maybe you can find some way to get it through you institution if you belong to one. It's a pretty standard textbook (the same guy wrote the mgcv package) so it really should be easy to find in any university library. $\endgroup$
    – jmarkov
    Commented Feb 16, 2023 at 6:53

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.