Model soybean growth with GAM
In this exercise, you will model the average leaf weight on a soybean plant as a function of time (after planting). As you will see, the soybean plant doesn't grow at a steady rate, but rather has a "growth spurt" that eventually tapers off. Hence, leaf weight is not well described by a linear model.
Recall that you can designate which variable you want to model non-linearly in a formula with the s()
(docs) function:
y ~ s(x)
Also remember that gam()
(docs) from the package mgcv
has the calling interface
gam(formula, family, data)
For standard regression, use family = gaussian
(the default).
The soybean training data, soybean_train
has been pre-loaded. It has two columns: the outcome weight
and the variable Time
. For comparison, the linear model model.lin
, which was fit using the formula weight ~ Time
has already been loaded as well.
This exercise is part of the course
Supervised Learning in R: Regression
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# soybean_train is available
summary(soybean_train)
# Plot weight vs Time (Time on x axis)
ggplot(soybean_train, aes(x = ___, y = ___)) +
geom_point()