Basic Generalised Additive Model In Ecology; Exercise

[This article was first published on R-exercises, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Generalised Additive Models (GAM) are non-parametric models that add smoother to the data. On this exercise, we will look at GAMs using cubic spline using the mgcv package. Dataset used can be downloaded here. The dataset is the experiment result at grassland richness over time in Yellowstone National Park (Skkink et al. 2007).
Answers to these exercises are available here. If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page. Load dataset and required package before running the exercise.

Exercise 1
observe the dataset and try to classify the response and explanatory variables. We will focus on ROCK as an explanatory variable.

Exercise 2
do some scatter plot

Exercise 3
since it is not linear, try to do GAM with ROCK variables

Exercise 4
check the result. what can be inferred

Exercise 5
do some validation plots

Exercise 6
plot base graph

Exercise 7
add predict across the data and add some lines

Exercise 8
plot the fitted values

Why we only use ROCK variables? Because it is proofed to give the most fitted data without incorporation all the explanatory variables. Try to play around with other explanatory variables to see the difference.

To leave a comment for the author, please follow the link and comment on their blog: R-exercises. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)