Refresher on fitting linear models
During this exercise, you'll see how a linear model is a special case of a generalized linear model (GLM).
You will use the ChickWeight (docs) dataset that we introduced during the video.
I have already extracted the last observed weights for you.
With the dataset, you will see if Diet affects weight at the end of the study.
Recall from the video that a linear model looks like lm(formula = y ~ x, data = dat) and that a GLM looks like glm(formula = y ~ x, data = dat, family = 'family').
This exercise is part of the course
Generalized Linear Models in R
Exercise instructions
- Fit a linear model with variable
weightpredicted by variableDietusing thechick_weight_enddataframe. - Fit a GLM using the same formula and data, but also include the
gaussianfamily.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Fit a lm()
lm(formula = ___ ~ ___, data = ___)
# Fit a glm()
glm(formula = ___ ~ ___ , data = ___, family = '___')