397 penguins-lm2
lm
en
regression
penguins
Schlüsselwörter
Aufgaben, Statistik, Prognose, Modellierung, R, Datenanalyse, Regression
397.1 Exercise
Consider the dataset penguins. Compute a linear model with body mass as output variable (DV) and a) flipper length and b) sex as input (IV).
- Tidy up the data set, if and where needed.
- Report the coefficients and interpret them.
- Plot the model and the coefficients.
- Report the model fit (R squared).
- BONUS:
predict()the weight of an average flipper-sized animal (male and female). Check out the internet for examples of how to do so in case you need support.
397.2 Solution
397.2.1 Setup
397.2.2 Tidy up
Note that, strangely, there are some animals for which the sex is reported as "", an empty string value. This is not the same as NA. However, we may want the exclude such animals of unclear sex.
397.2.3 Let’s go
lm2 <-
lm(body_mass_g ~ flipper_length_mm + sex,
data = penguins_tidier)Plot the model:
plot(estimate_relation(lm2))