BaşlayınÜcretsiz başlayın

Running a model

The smooth trend line you saw in the plots of yield over time use a generalized additive model (GAM) to determine where the line should lie. This sort of model is ideal for fitting nonlinear curves. So we can make predictions about future yields, let's explicitly run the model. The syntax for running this GAM takes the following form.

gam(response ~ s(explanatory_var1) + explanatory_var2, data = dataset)

Here, s() means "make the variable smooth", where smooth very roughly means nonlinear.

mgcv and dplyr are loaded; the corn and wheat datasets are available and have been expanded to include metric units and census region information.

Bu egzersiz, kursun bir parçasıdır

Introduction to Writing Functions in R

Kursa Göz Atın

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

# Run a generalized additive model of yield vs. smoothed year and census region
___(___ ~ s(___) + ___, data = ___)
Kodu Düzenle ve Çalıştır