I am strangling to find the right modeling method for my data. Short explain of the dataset : I have a variable called alpha diversity ( Alpha diversity refers to the average species diversity in a habitat or specific area. Alpha diversity is a local measure) and we want to see the effect of environmental( n=9) variables on it

Here is the scatter plots of each variables x Alpha diversity(Shannon) As you can see the relationship is not at all linear and that's why I decided to use GAM.

But I am not sure if its the appropriate way of modeling because for some variables( e.g distance from the city) the distribution its not continuous.

I will appreciate any help on it

[UPDATE] Hey again I took some time to think yours comment. I checked the relationships again by superimposing a loess fit via geom_smooth and it looks like this ( blue line linear , red loess) enter image description here I get that in some of the variables we don't see any relationship e.g ( Shannon-Distance from the city) However I ran a GAM as follows

GAM1 <- gam(Shannon ~ s(Distance_from_city_centre, bs = 'cr', k = 5)+
          s(Light_complete_100m, bs = 'cr', k = 5)+
          s(Temperature_Celsius, bs = 'cr', k = 5)+
          s(Human_presence, bs = 'cr', k = 5)+
          s(NDVI, bs = 'cr', k = 5)+
          s(Sound_dbC, bs = 'cr', k = 5)+
          s(Closest_Road_m, bs = 'cr', k = 5)+
          s(Closest_Path_m, bs = 'cr', k = 5)+
          s(Tree_cover, bs = 'cr', k = 5),
        data=data_stats_model,method = "REML") 

The summary : enter image description here

From the edf I see that many of the variables are close to linear ( edf=1) So I run the model again like this

GAM4 <- gam(Shannon ~ s(Distance_from_city_centre, bs = 'cr', k = 20) +
          Light_complete_100m +
          Temperature_Celsius +
          s(Human_presence, bs = 'cr', k = 25)+
          s(Closest_Road_m, bs = 'cr', k = 5)+
          s(Closest_Path_m, bs = 'cr', k = 5)+
        data=data_stats_model, method = "REML") 

And the summary : enter image description here

My questions are :

  1. Is this the right strategy ?
  2. How to handle the multicollinearity? When I ran LMM for the same data I used the VIF strategy

I would really appreciate any help Thanks again, A

  • $\begingroup$ Yes, it seems nothing is wrong. From the values I suspect that probably $\alpha$ isn't Gaussian (so maybe Gamma or Inverse Gaussian are more appropriate) but aside that you are on the clear. $\endgroup$
    – usεr11852
    Feb 28, 2021 at 14:03
  • $\begingroup$ Thanks a lot !! $\endgroup$ Mar 1, 2021 at 9:28

1 Answer 1


It's hard to see nonlinear relationships in your scatterplots by eye unless you superimpose a loess fit - that would be easy to do in R via the geom_smooth() function of the ggplot2 package. (If anything, it looks like there are no relationships in some of those plots - linear or nonlinear.)

Even if you see nonlinear relationships in some or all of those scatterplots after superimposing a loess fit, you have to remember that the scatterplots only show marginal relationships (i.e., relationships between the response variable and a particular predictor, ignoring all other predictors). Marginal relationships may or may not have any bearing on conditional relationships (i.e., relationships between the response variable and a particular predictor, controlling for all other predictors).

Here is a simple example illustrating the difference between marginal and conditional relationships. Suppose you have a random sample of students from a target population for whom you measured the following variables: height, weight and waist circumference. You are interested in studying how height (response variable) varies with weight and waist circumference (predictor variables).

If you plot height against weight, that will help illuminate the marginal relationship between height and weight - that is, the relationship between height and weight among all students in your population, regardless of their waist circumference.

The conditional relationship between height and weight is different from the marginal one because it refers only to those students in the target population who have the same waist circumference (e.g., 34 inches).

So deciding whether or not a GAM model is adequate for your data cannot simply rely on a visual examination of the scatterplots you shared. Typically, the choice of model is informed by a combination of the following:

  1. Background knowledge on research subject;
  2. Research question(s);
  3. Study design;
  4. Data considerations;
  5. Software availability;
  6. Skill of data analyst;
  7. Ease of interpretation;
  8. Time and budget constraints.

In your case, if you have reasons to believe that the relationship between at least one predictor and your response variable is nonlinear (controlling for the other predictors in your model), then you would feel more justified in using a GAM.

However, GAMs are flexible models - even if you had no relationship or a linear (rather than a nonlinear) relationship between the response variable and a particular predictor, ignoring all other predictors, a GAM model will be able to cope with that.

Note: Thank you to Dr. Berna Devezer for suggesting the first item in the list of model-choice factor.

  • $\begingroup$ Thanks a lot for your detailed answer I will check the conditional relationships! $\endgroup$ Mar 1, 2021 at 9:30

Your Answer

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