Basic Linear Regression
James H. Steiger
Department of Psychology and Human Development Vanderbilt University
James H. Steiger (Vanderbilt University) 1 / 40
Basic Linear Regression James H. Steiger Department of Psychology - - PowerPoint PPT Presentation
Basic Linear Regression James H. Steiger Department of Psychology and Human Development Vanderbilt University James H. Steiger (Vanderbilt University) 1 / 40 Basic Linear Regression Fitting a Straight Line 1 Introduction Characteristics of
James H. Steiger (Vanderbilt University) 1 / 40
James H. Steiger (Vanderbilt University) 2 / 40
James H. Steiger (Vanderbilt University) 3 / 40
We begin by recalling our data relating height to shoe size and drawing the scatterplot for the male data.
> all.heights <- read.csv("shoesize.csv") > male.data <- all.heights[all.heights$Gender == "M", ] #Select males > attach(male.data) #Make Variables Available > # Draw scatterplot > plot(Size, Height, xlab = "Shoe Size", ylab = "Height in Inches") 8 10 12 14 65 70 75 80 Shoe Size Height in Inches
James H. Steiger (Vanderbilt University) 4 / 40
James H. Steiger (Vanderbilt University) 5 / 40
Fitting a Straight Line Introduction
James H. Steiger (Vanderbilt University) 6 / 40
Fitting a Straight Line Introduction
1
2
James H. Steiger (Vanderbilt University) 7 / 40
Fitting a Straight Line Characteristics of a Straight Line
James H. Steiger (Vanderbilt University) 8 / 40
Fitting a Straight Line Characteristics of a Straight Line
James H. Steiger (Vanderbilt University) 9 / 40
Fitting a Straight Line Characteristics of a Straight Line
James H. Steiger (Vanderbilt University) 10 / 40
Fitting a Straight Line Characteristics of a Straight Line
1 2 3 4 5 1 2 3 4 5 X Y (2,3)
James H. Steiger (Vanderbilt University) 11 / 40
Fitting a Straight Line Characteristics of a Straight Line
James H. Steiger (Vanderbilt University) 12 / 40
Fitting a Straight Line Characteristics of a Straight Line
1 2 3 4 5 1 2 3 4 5 X Y
James H. Steiger (Vanderbilt University) 13 / 40
Fitting a Straight Line Characteristics of a Straight Line
James H. Steiger (Vanderbilt University) 14 / 40
Fitting a Straight Line Characteristics of a Straight Line
1 2 3 4 5 1 2 3 4 5 X Y Y ^ Y E
James H. Steiger (Vanderbilt University) 15 / 40
Fitting a Straight Line Regression Notation
James H. Steiger (Vanderbilt University) 16 / 40
Fitting a Straight Line The Least Squares Solution
James H. Steiger (Vanderbilt University) 17 / 40
Fitting a Straight Line The Least Squares Solution
James H. Steiger (Vanderbilt University) 18 / 40
Fitting a Straight Line The Least Squares Solution
James H. Steiger (Vanderbilt University) 19 / 40
Predicting Height from Shoe Size Creating a Fit Object
James H. Steiger (Vanderbilt University) 20 / 40
Predicting Height from Shoe Size Examining Summary Statistics
James H. Steiger (Vanderbilt University) 21 / 40
Predicting Height from Shoe Size Examining Summary Statistics
James H. Steiger (Vanderbilt University) 22 / 40
Predicting Height from Shoe Size Examining Summary Statistics
James H. Steiger (Vanderbilt University) 23 / 40
Predicting Height from Shoe Size Examining Summary Statistics
James H. Steiger (Vanderbilt University) 24 / 40
Predicting Height from Shoe Size Examining Summary Statistics
James H. Steiger (Vanderbilt University) 25 / 40
Predicting Height from Shoe Size Drawing the Regression Line
James H. Steiger (Vanderbilt University) 26 / 40
Predicting Height from Shoe Size Drawing the Regression Line
8 10 12 14 65 70 75 80 Size Height
James H. Steiger (Vanderbilt University) 27 / 40
Predicting Height from Shoe Size Using the Regression Line
James H. Steiger (Vanderbilt University) 28 / 40
Predicting Height from Shoe Size Using the Regression Line
James H. Steiger (Vanderbilt University) 29 / 40
Predicting Height from Shoe Size Using the Regression Line
James H. Steiger (Vanderbilt University) 30 / 40
Predicting Height from Shoe Size Using the Regression Line
James H. Steiger (Vanderbilt University) 31 / 40
Partial Correlation An Example
James H. Steiger (Vanderbilt University) 32 / 40
Partial Correlation An Example
James H. Steiger (Vanderbilt University) 33 / 40
Partial Correlation An Example
James H. Steiger (Vanderbilt University) 34 / 40
Partial Correlation An Example
0.0 0.5 1.0 1.5 2.0 2.5 3.0 20 40 60 80 100 120 140 Trucks Damage
James H. Steiger (Vanderbilt University) 35 / 40
Partial Correlation An Example
James H. Steiger (Vanderbilt University) 36 / 40
Partial Correlation An Example
James H. Steiger (Vanderbilt University) 37 / 40
Partial Correlation An Example
There are several ways we can compute this partial correlation. One way is to compute the two residual variables discussed above, and then compute the correlation between them.
> fit.1 <- lm(Trucks ~ FireSize) > fit.2 <- lm(Damage ~ FireSize) > E.1 <- residuals(fit.1) > E.2 <- residuals(fit.2) > plot(E.1, E.2) −0.3 −0.2 −0.1 0.0 0.1 0.2 0.3 −1.0 −0.5 0.0 0.5 1.0 1.5 2.0 E.1 E.2 > cor(E.1, E.2) [1] -0.2163
James H. Steiger (Vanderbilt University) 38 / 40
Partial Correlation An Example
James H. Steiger (Vanderbilt University) 39 / 40
Partial Correlation An Example
James H. Steiger (Vanderbilt University) 40 / 40