lesson 2: linear regression - wordpress.com › 2016 › 02 › ... · learn about linear...
TRANSCRIPT
![Page 1: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/1.jpg)
Lesson 2: Linear Regression
![Page 2: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/2.jpg)
Learn about linear regression
This Lesson’s Goals
Summarise results in an R Markdown document
Do a linear regression in R
Make a figure for data from a linear regression
![Page 3: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/3.jpg)
Math
![Page 4: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/4.jpg)
yi = a + bxi + ei
yi = specific y value (dependent variable)
a = intercept
b = slope
xi = specific x value (independent variable)
ei = random variance or the residual
![Page 5: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/5.jpg)
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
● ●
●●
●
●
●
●
●
●
●
●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ● ●
● ● ●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●● ●
● ● ●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●● ● ● ●
●● ●
●
●●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
● ● ● ● ● ●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
● ● ● ●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
● ●
0
100
200
300
0 5 10 15 20Time
Wei
ght i
n gr
ams
Chick Weight Over Time
yi = a + bxi + ei
![Page 6: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/6.jpg)
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
● ●
●●
●
●
●
●
●
●
●
●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ● ●
● ● ●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●● ●
● ● ●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●● ● ● ●
●● ●
●
●●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
● ● ● ● ● ●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
● ● ● ●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
● ●
0
100
200
300
0 5 10 15 20Time
Wei
ght i
n gr
ams
Chick Weight Over Time
yi = a + bxi + ei
![Page 7: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/7.jpg)
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
● ●
●●
●
●
●
●
●
●
●
●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ● ●
● ● ●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●● ●
● ● ●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●● ● ● ●
●● ●
●
●●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
● ● ● ● ● ●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
● ● ● ●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
● ●
0
100
200
300
0 5 10 15 20Time
Wei
ght i
n gr
ams
Chick Weight Over Time
yi = a + bxi + ei
![Page 8: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/8.jpg)
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
● ●
●●
●
●
●
●
●
●
●
●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ● ●
● ● ●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●● ●
● ● ●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●● ● ● ●
●● ●
●
●●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
● ● ● ● ● ●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
● ● ● ●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
● ●
0
100
200
300
0 5 10 15 20Time
Wei
ght i
n gr
ams
Chick Weight Over Time
yi = a + bxi + ei
![Page 9: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/9.jpg)
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
● ●
●●
●
●
●
●
●
●
●
●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ● ●
● ● ●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●● ●
● ● ●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●● ● ● ●
●● ●
●
●●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
● ● ● ● ● ●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
● ● ● ●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
● ●
0
100
200
300
0 5 10 15 20Time
Wei
ght i
n gr
ams
Chick Weight Over Time
yi = a + bxi + ei
![Page 10: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/10.jpg)
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
● ●
●●
●
●
●
●
●
●
●
●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ● ●
● ● ●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●● ●
● ● ●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●● ● ● ●
●● ●
●
●●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
● ● ● ● ● ●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
● ● ● ●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
● ●
0
100
200
300
0 5 10 15 20Time
Wei
ght i
n gr
ams
Chick Weight Over Time
yi = a + bxi + ei
![Page 11: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/11.jpg)
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
● ●
●●
●
●
●
●
●
●
●
●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ● ●
● ● ●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●● ●
● ● ●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●● ● ● ●
●● ●
●
●●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
● ● ● ● ● ●● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
● ● ● ●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
● ●
0
100
200
300
0 5 10 15 20Time
Wei
ght i
n gr
ams
Chick Weight Over Time
yi = a + bxi + ei
![Page 12: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/12.jpg)
categorical?
yi = a + bxi + ei
![Page 13: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/13.jpg)
continuouspredictors
categoricalpredictors
x = a set of continuous data points
a + bx
x = a set of binary/categorical data points
a = the value of y when x is 0
a = the value of y when the x is the default level
b = the change in y for one change in x
b = the change in y when x is the non-default level
![Page 14: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/14.jpg)
yi = a + bxi + ei
●
900
950
1000
1050
1100
high lowProficiency in L2
Rea
ctio
n tim
es in
ms
Reaction Times by L2 Proficiency Level
0 1
![Page 15: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/15.jpg)
yi = a + bxi + ei
●
●
●
●●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●●●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●●
900
950
1000
1050
1100
high lowProficiency in L2
Rea
ctio
n tim
es in
ms
Reaction Times by L2 Proficiency Level
0 1
![Page 16: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/16.jpg)
yi = a + bxi + ei
●
●
●
●●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●●●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●●
900
950
1000
1050
1100
high lowProficiency in L2
Rea
ctio
n tim
es in
ms
Reaction Times by L2 Proficiency Level
0 1
![Page 17: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/17.jpg)
yi = a + bxi + ei
●
●
●
●●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●●●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●●
900
950
1000
1050
1100
high lowProficiency in L2
Rea
ctio
n tim
es in
ms
Reaction Times by L2 Proficiency Level
0 1
![Page 18: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/18.jpg)
yi = a + bxi + ei
●
●
●
●●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●●●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●●
900
950
1000
1050
1100
high lowProficiency in L2
Rea
ctio
n tim
es in
ms
Reaction Times by L2 Proficiency Level
0 1
![Page 19: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/19.jpg)
yi = a + bxi + ei
●
●
●
●●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●●●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●●
900
950
1000
1050
1100
high lowProficiency in L2
Rea
ctio
n tim
es in
ms
Reaction Times by L2 Proficiency Level
0 1
![Page 20: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/20.jpg)
yi = a + bxi + ei
●
●
●
●●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●●●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●●
900
950
1000
1050
1100
high lowProficiency in L2
Rea
ctio
n tim
es in
ms
Reaction Times by L2 Proficiency Level
0 1
![Page 21: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/21.jpg)
yi = a + bxi + ei
●
●
●
●●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●●●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●●
900
950
1000
1050
1100
high lowProficiency in L2
Rea
ctio
n tim
es in
ms
Reaction Times by L2 Proficiency Level
0 1
![Page 22: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/22.jpg)
yi = a + bxi + ei
●
●
●
●●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●●●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●●●
900
950
1000
1050
1100
high lowProficiency in L2
Rea
ctio
n tim
es in
ms
Reaction Times by L2 Proficiency Level
0 1
![Page 23: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/23.jpg)
R Code
![Page 24: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/24.jpg)
yi = a + bxi + ei
lm(weight ~ Time)
![Page 25: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/25.jpg)
yi = a + bxi + ei
lm(rt ~ type)
![Page 26: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/26.jpg)
Lab
![Page 27: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/27.jpg)
Dataset: Baby names per year from USA Social Security Administration
Continuous Predictor: Does your name get more or less popular between the years of 1901 and 2000?
Categorical Predictor: Is your name more or less popular with females or males?
yi = a = b = xi = ei =
frequency of name? - will get from model? - will get from modelyear? - will get from model
yi = a = b = xi = ei =
frequency of name? - will get from model? - will get from modelsex? - will get from model
Continuous Predictor Categorical Predictor
source: R package “babynames”
![Page 28: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/28.jpg)
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
−5.5
−5.0
−4.5
1925 1950 1975 2000Year
Prop
ortio
n of
Peo
ple
(log
base
10
trans
form
ed)
Proportion of People withthe Name 'Page' Over Time
End of Lesson Food for Thought
![Page 29: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/29.jpg)
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
−5.5
−5.0
−4.5
1925 1950 1975 2000Year
Prop
ortio
n of
Peo
ple
(log
base
10
trans
form
ed)
Proportion of People withthe Name 'Page' Over Time
End of Lesson Food for Thought
![Page 30: Lesson 2: Linear Regression - WordPress.com › 2016 › 02 › ... · Learn about linear regression This Lesson’s Goals Summarise results in an R Markdown document Do a linear](https://reader034.vdocuments.site/reader034/viewer/2022042315/5f044f597e708231d40d57ee/html5/thumbnails/30.jpg)
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●●
●
●
●
●
●
●
●
●●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
−5.5
−5.0
−4.5
1925 1950 1975 2000Year
Prop
ortio
n of
Peo
ple
(log
base
10
trans
form
ed)
Proportion of People withthe Name 'Page' Over Time
End of Lesson Food for Thought