Generalized Additive Models (GAM) are non-parametric models that add smoother to the data. In this exercise, we will look at GAMs using cubic spline using the mgcv
package. Data-sets used can be downloaded here. The data-set is the experiment result of grassland richness over time in the 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 the data-set and required package before running the exercise.
Exercise 1
Observe the data-set and try to classify the response and explanatory variables. We will focus on ROCK as an explanatory variable.
Exercise 2
Do some scatter-plots.
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 the base graph.
Exercise 7
Add “predict” across the data and add some lines.
Exercise 8
Plot the fitted values.
Why do we only use ROCK variables? It is proven to give the most fitted data without incorporation of all the explanatory variables. Try to play around with other explanatory variables to see the difference.
Leave a Reply