Challenge: Fitting The Linear Regression Model
Use what you've learned so far to complete the following challenge.
We'll cover the following
Darwin’s wild Mignonette data
The Mignonette data
Format
This data frame contains the following columns:
cross
: heights of the crosspollinated plants.self
: heights of the selfpollinated plants.
Problem statement
Write a piece of code in R that reads Mignonette’s data frame from the DAAG package, and do the following operations:

Display the first few rows of Mignonette’s data frame.

Produce a table of the summary statistics.

Fit the linear regression model to the Mignonette data.
Output
# cross self
# 1 21.000 12.875
# 2 14.250 16.000
# 3 19.125 11.875
# 4 7.000 15.250
# 5 15.125 19.125
# 6 20.500 12.500
# cross self
# Min. : 7.00 Min. : 7.875
# 1st Qu.:14.91 1st Qu.:12.781
# Median :17.56 Median :14.625
# Mean :17.18 Mean :14.620
# 3rd Qu.:20.56 3rd Qu.:16.250
# Max. :25.25 Max. :20.875
# lm(formula = cross ~ self, data = mignonette)
# coef.est coef.se
# (Intercept) 19.38 4.78
# self 0.15 0.32

# n = 24, k = 2
# residual sd = 4.80, RSquared = 0.01
Coding exercise
This problem has been designed for you to practice freely, so try to solve it on your own first. Take some time and think about the different concepts that we’ve explored in this course so far.
If you’re feeling stuck, you can always check out the solution in the next lesson.
Good luck!
Get handson with 1200+ tech skills courses.