Docsity

Least-Squares Regression - Lecture Notes | MATH 203, Study notes of Statistics

Toggle sidebar
bg1
Dr. Neal, Spring 2009
MATH 203 Least-Squares Regression
As well as finding the correlation of paired data {{ x
1
, y
1
}, { x
2
, y
2
}, . . ., {xn, yn}}, we also
can plot the data with a scatterplot and find the Least Squares Line of Best Fit through the
data. This line, having equation y=a x +b, provides an approximate linear functional
relationship between the values of xi and yi. Of course, it is only a “good fit” if the
correlation is near
±1
, which means that there is a strong linear dependence between
the measurements
X
and
Y
.
The slope
a
is given by
a
= x y−(x )(y )
x2−(x )2,
where x y = 1
nxiyi
i=1
n
∑
and x2 = 1
nxi2
i=1
n
∑
.
After the slope
a
is calculated, then
the intercept
b
is given by
b
= y −a
x
.
Then
Y
≈ a X +b.
This least squares line is the line that minimizes the “sum of squared errors”
between the actual yi values and the linear approximations ax
. That is, the sum
(axi+b−yi)2
i=1
n
∑
is minimized with these choices of
a
and
b
.
To compute both the correlation and the least-squares line, enter paired data into
lists L1 and L2 (or some other pair of lists), press STAT, scroll to CALC, press 4 for
LinReg(ax+b), then enter the command LinReg(ax+b) L1, L2.
Some Other Quick Facts
1. The point (
x
,
y
) is always on the least-squares regression line.
2. The slope of the least-squares regression line also is given by a=r˜ X
˜
Y
, where
r
is
the sample correlation, ˜
X=x2−x
( )
2
, and ˜
Y=y2−y ( )2
.
3. The value
r2
is the coefficient of determination. It measures the proportion of the
observed values accounted for by the regression fit. Because
0≤r2≤1
, an
r2
near 1
means that there is a strong fit, and an
r2
near 0 means that there is virtually no fit of
the data.
pf3
pf4
pf5

Partial preview of the text

Download Least-Squares Regression - Lecture Notes | MATH 203 and more Study notes Statistics in PDF only on Docsity!

MATH 203 Least-Squares Regression

As well as finding the correlation of paired data {{ x 1 , y 1 }, { x 2 , y 2 },.. ., { xn , yn }}, we also

can plot the data with a scatterplot and find the Least Squares Line of Best Fit through the data. This line, having equation y = a x + b , provides an approximate linear functional

relationship between the values of xi and yi. Of course, it is only a “good fit” if the

correlation is near ± 1 , which means that there is a strong linear dependence between the measurements X and Y.

The slope a is given by

a =

x y − ( x )( y )

x^2 − ( x )^2

where x y =

n

xi yi i = 1

n

∑ and^ x

n

xi^2 i = 1

n

After the slope a is calculated, then the intercept b is given by

b = y − a x.

Then Y ≈ a X + b.

This least squares line is the line that minimizes the “sum of squared errors” between the actual yi values and the linear approximations ax (^) i + b. That is, the sum

( axi + b − yi )^2 i = 1

n

∑ is minimized with these choices of^ a^ and^ b^.

To compute both the correlation and the least-squares line, enter paired data into lists L1 and L2 (or some other pair of lists), press STAT , scroll to CALC , press 4 for LinReg(ax+b) , then enter the command LinReg(ax+b) L1, L.

Some Other Quick Facts

  1. The point ( x , y ) is always on the least-squares regression line.
  2. The slope of the least-squares regression line also is given by a =

r ˜^ X ˜ (^) Y

, where r is

the sample correlation, ˜^ X = x^2 − (^ x )^2 , and ˜^ Y = y^2 − ( y )^2.

  1. The value r^2 is the coefficient of determination. It measures the proportion of the

observed values accounted for by the regression fit. Because 0 ≤ r^2 ≤ 1 , an r^2 near 1

means that there is a strong fit, and an r^2 near 0 means that there is virtually no fit of the data.

Examples. (i) Make a scatterplot; (ii) Compute r and explain what it means; (iii) Find the equation of the least-squares regression line and graph it through the scatterplot.

  1. Is there a relationship between the tar and nicotine levels in cigarettes?

Brand Tar (mg) Nicotine (mg) Alpine 14.1 0. Benson & Hedges 16.0 1. Bull Durham 29.8 2. Camel Lights 8.0 0. Carlton 4.1 0. Chesterfield 15.0 1. Golden Lights 8.8 0. Kent 12.4 0. Kool 16.6 1. L&M 14.9 1.

STAT EDIT STAT PLOT Adjust Settings ZOOM 9

We see the general trend: As the tar level increases, then the nicotine level increases.

STAT CALC Enter command r ≈ 0.

Because r is so close to +1, there is a strong positive linear relationship between tar and nicotine.

The least-squares regression line is given by y = a x + b ≈ 0.0610475 x + 0.. Due to the close fit, this linear function could be used to predict a nicotine level y for a given tar level x. For instance, if x = 20 mg of tar, then y ≈ 1.359 mg of nicotine.

Y= From VARS STATISTICS EQ Press ENTER

Press GRAPH From CALC ( 2nd TRACE) value, X = 20

Because r^2 ≈ 0.974, nicotine level is 97.4% determined by tar level when using y = 0.0610475 x + 0.138167 as a predictor, and 2.6% determined by other factors.

  1. Is there a relationship between driving speed and MPG for your gas-guzzling SUV?

Speed (mph) MPG 10 18 20 20 40 22 60 20 70 18

STAT EDIT STAT PLOT Adjust Settings ZOOM 9

There clearly seems to be some sort of relationship (perhaps quadratic). The mpg increases as speed increases to a certain point; but then as speed increases further, the mpg drops off.

STAT CALC r = 0.

There is no correlation!

The correlation measures the strength and direction of the linear association between the variables. Just because the correlation equals 0, it does not mean that there is no relationship. In this case, there simply is not a permanent linear relationship between speed and mpg; but there certainly is a relationship.

Here, the least-squares regression line is constant and is given by y = 19..

Press GRAPH

In this case, the least-squares regression line is not a good fit of the data. However, it is the best linear approximation of the data, which really does no good here because there is no permanent linear relationship between speed and mpg.

Because r^2 = 0, the line does not fit the data at all. Using the line y = 19.6 as a predictor, then the mpg is not at all determined by its speed.

  1. Is there a relationship between height and GPA? The following data is a collection of measurements from a random sample of WKU students.

Student Height (inches) GPA

  1. 60.5 3.
  2. 69.5 2.
  3. 69.5 2.
  4. 71.5 3.
  5. 73 1.
  6. 65.5 2.
  7. 75 3.
  8. 68 3.
  9. 64 2.
  10. 61 2.

STAT EDIT STAT PLOT Adjust Settings ZOOM 9

There does not appear to be any relationship between height and grade point average. High and low (and middle) GPAs are attained from students of all heights.

STAT CALC r ≈ –0.

The correlation is nearly 0.

When there is no relationship whatsoever between the variables, then we say that they are independent. When variables are independent, then the true correlation will equal 0. So the correlation coefficient from a random sample of measurements should be very close to 0 when the two variables have no association between them.

Here, the least-squares regression line is given by y = −0.007754 x + 3..

Press GRAPH

Because the correlation is nearly 0, there is no linear relationship between height and GPA. (In fact, there is no relationship at all because GPA is independent of height.) So again, the least-squares regression line is not a good fit of the data.

Because r^2 ≈ 0.0035, less than 1% of a person‘s GPA is determined by height when using the line y = −0.007754 x + 3.3663446 as a predictor.