LoslegenKostenlos loslegen

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').

Diese Übung ist Teil des Kurses

Generalized Linear Models in R

Kurs anzeigen

Anleitung zur Übung

  • Fit a linear model with variable weight predicted by variable Diet using the chick_weight_end dataframe.
  • Fit a GLM using the same formula and data, but also include the gaussian family.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Fit a lm()
lm(formula = ___ ~ ___, data = ___)

# Fit a glm()
glm(formula = ___ ~ ___ , data = ___, family = '___')
Code bearbeiten und ausführen