Multivariate GAMs of auto performance
GAMs can accept multiple variables of different types. In the following exercises, you'll work with the mpg dataset available in the gamair package to practice fitting models of different forms.
Bu egzersiz
Nonlinear Modeling with Generalized Additive Models (GAMs) in R
kursunun bir parçasıdırEgzersiz talimatları
- Use the
head()andstr()functions to examine thempgdata set. - Fit a GAM to these data to predict
city.mpgas the sum of smooth functions ofweight,length, andprice. - Use the
plot()function provided to visualize the model.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
library(mgcv)
# Examine the data
___
___
# Fit the model
mod_city <- gam(city.mpg ~ ___,
data = mpg, method = "REML")
# Plot the model
plot(mod_city, pages = 1)