Adding categorical to the auto performance model
Now you'll include categorical variables in your model. Categories are inherently linear, so you'll model them as linear terms.
Bu egzersiz
Nonlinear Modeling with Generalized Additive Models (GAMs) in R
kursunun bir parçasıdırEgzersiz talimatları
- Fit a GAM to the
mpgdata, modelingcity.mpgas a sum of smooth functions ofweight,length, andprice, and also include the categorical termsfuel,drive, andstyle. - Use the
plot()function provided to visualize the model.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
library(mgcv)
# Fit the model
mod_city2 <- gam(city.mpg ~ s(weight) + s(length) + s(price) ___,
data = mpg, method = "REML")
# Plot the model
plot(mod_city2, all.terms = TRUE, pages = 1)