Pollution models with multi-scale interactions
The meuse
dataset contains some predictor variables that are on the same scale (x
, y
), and some that are on different scales (elev
, dist
, om
). In a previous exercise, you fit a model where you predicted cadmium pollution as a function of location and elevation:
mod <- gam(cadmium ~ s(x, y) + s(elev),
data = meuse, method = "REML")
In this exercise, you'll build a model that allows multiple variables to interact despite these different scales using a tensor smooth, te()
.
Diese Übung ist Teil des Kurses
Nonlinear Modeling with Generalized Additive Models (GAMs) in R
Anleitung zur Übung
- Convert this to a model where
x
,y
, andelev
all interact in a singlete()
term, varying on their own scales. - Then summarize the model and visualize it with
plot()
.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# Fit the model
tensor_mod <- ___
# Summarize and plot
___
___