MulaiMulai sekarang secara gratis

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

Latihan ini adalah bagian dari kursus

Generalized Linear Models in R

Lihat Kursus

Petunjuk latihan

  • 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.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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

# Fit a glm()
glm(formula = ___ ~ ___ , data = ___, family = '___')
Edit dan Jalankan Kode