


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















Chapter 9 Linear Regression and Correlation
As in the previous chapter, we are interested in the
presence of an association or independence between two
random variables. However, there are two main
differences in this chapter:
quantitative
between the response and the explanatory variable.
The response is also called the dependent variable
(usually denoted by Y and always shown on the vertical
axis of a scatter diagram).
The explanatory variable is the independent variable
(usually denoted by X and always shown on the
horizontal axis of a scatter diagram). The explanatory
variable is also called the predictor because it helps to
predict the values of response.
9.1 Linear Relationship
The response (Y) is hypothesized as a linear function of
the independent variable (X). Thus we have the following
Simple Linear Regression (SLR) model.
Alternatively, we may take the expected values (means)
of both sides of the above relation and show the relation
between these variables as
Y
. This is called
the true regression line. In this case we are using the
assumption that Y is a random variable, X is a variable
(not random) and the mean of the error term E() = 0.
In the above equations
Y = response (dependent variable), is a random
variable that has a normal distribution with mean
Y
and standard deviation .
X = explanatory variable (independent variable). It is
a non-random variable.
= Intercept (y-intercept) = Value of Y when X = 0.
[Note that this interpretation may not always be
meaningful. Extra care is needed in interpreting the
intercept.]
= Slope = Change in Y for one unit increase in X.
= Error term (residual) that takes into account of all
other factors that are not in the model but which
influence the values of Y, assumed to have a
mean of zero and standard deviation .
9.2 Least squares Prediction Equation
Scatter Diagram:
The first step of fitting a linear regression model to the
data is to look at the data in a graph. Before we start the
estimation and prediction process, we first draw a scatter
diagram or scatter plot of the data. Such a diagram will
give us two important bits of information:
a) Does the relation between X and Y look linear?
b) What can we say about the slope and the strength of
the relationship?
A scatter diagram is a plot of the (x,y) pairs on a two-
dimensional graph with Y on the vertical axis and X on
the horizontal axis.
Examples of some scatter diagrams:
Example: Suppose we are interested in investigating
whether there is a linear relationship between
Mileage of cars (mpg) and
Horse power of Cars
Observe that both variables are quantitative. Which one of
these is the dependent variable (response) and which one
is the independent (explanatory) variable?
From the observed data on the 382 cars we get the
following scatter diagram:
Figure – 1. A Scatter Diagram of
Mileage vs. Horse Power
Linear Regression
50 100 150 200
Horsepower
10
20
30
40
Miles per Gallon
Miles per Gallon = 39.85 + -0.16 * horse
R-Square = 0.
What can we say about the relationship between the two
variables?
Residual analyses
The prediction equation provides predicted values for Y
(mpg) using the horse power of each car as the predictor
(independent) variable. The difference between the
observed and the predicted values give the residuals.
For example, for a car that has hp = 130, the prediction
equation gives
y . . hp . . .
For the first car, the observed mileage is 18, hence the
corresponding residual is = 18 – 19.4 = – 1.4. The
following table gives the values of y, x,
y
and residual for
the first 10 observations in the sample. Verify them, to
see if you’ve understood the concept of residuals.
Observed
Value (y)
Horse
power (x)
Predicted
value (
y
)
Residual
y y
18
15
18
16
17
15
14
14
14
15
130
165
150
150
140
198
220
215
225
190
Effect of outliers on the prediction equation
One of the reasons we are interested in the residuals is to
see if there is any outliers in the data set. Such outliers
will have large residuals (in absolute value) and may
influence the estimates of the parameters and hence the
predictions, by pulling the prediction line upwards or
downwards. We call these observations influential points
and must carry out the analyses without them if they
cannot be corrected. [Note that some outliers may have no
significant effect on the estimates.] The crucial question
is of course, how large is large? For this it is better to look
at the standardized residuals, which is the residuals
divided by their standard deviation.
Method of Least Squares
The parameters are estimated using a method called the
least squares estimation (LSE). In this method, values of a
and b are determined in such a way that
a) The sum of the residuals is zero and
b) The sum of the squared residuals is a minimum, i.e.,
2
1
n
i i
i
SSE ( y y )
is minimized.
The formula for a and b given above satisfy both of these
conditions. For this reason, the prediction equation is also
called the least squares line. The value of the SSE that
uses these values of a and b is the smallest among all
The denominator (n – 2) is the degrees of freedom. We
lost two degrees of freedom because we estimated two
unknown parameters ( and ).
Statistical software give the SSE as well as the df and
divides them to give an estimate of the variance (called
the mean squared error), as seen in the following output
(called the ANOVA table) for the cars data:
ANOVA Table
Model
Sum of
Squares df Mean Square F Sig.
1 Regression 14169.756 1 14169.756 572.709 .000(a)
Residual
9649.
390 24.
Total
23818.993 391
a Predictors: (Constant), Horsepower
b Dependent Variable: Miles per Gallon
Hence the mean squared (MSE) error is
2
The square root of the mean squared error is called the
root mean square and is an estimate of the standard
deviation of the population of Y’s. Hence, from the above
output we can write
Root mean square =
24 742 4 97
The residuals in the car data are all divided by 4.97 to
give the standardized residuals.
The following output shows that the standardized
residuals, are in the range from – 3.259 to + 3.414. Hence
there may be a few influential points in the data set.
Residuals Statistics(a)
Minimum Maximum Mean Std. Deviation N
Predicted Value 3.64 32.61 23.45 6.020 392
Residual -16.212 16.980 .000 4.968 392
Std. Predicted Value
-3.290 1.523 .000 1.000 392
Std. Residual
-3.259 3.
.000 .999 392
a Dependent Variable: Miles per Gallon
r = 1 exactly when there is a perfect linear
relation between X and Y, i.e., when all data points
are on the estimated regression line. Then, there is
no prediction error in Y = a + bX.
The further away r is from zero, the stronger is the
linear association between X and Y. Thus r = – 0.
indicates a stronger association than r = + 0.6.
The correlation coefficient is a unitless measure,
i.e., its value does not depend on units of
measurement.
Correlation between X and Y is the same as the
correlation between Y and X (this is not true for
slope though!).
Correlation can also be interpreted as
“standardized slope” in the sense that an increase
in X by one standard deviation (S
X
) will result in a
change of r standard deviations (S
Y
) in Y. This is
seen in the following relationship: S
X
b = rS
Y
. This
comes from the equality r = (S
X
Y
)×b, obtained by
cross-multiplication.
A PRE = Proportional Reduction in Error Measure:
The coefficient of Determination (R
2
The coefficient of determination (R
2
) is the square of the
correlation coefficient, (r)
2
, sometimes expressed as a
percentage, i.e., R
2
= 100×(r)
2
Properties of R
2
2
= (r)
2
= (r)
2
2
1
2
≤ 1 or 0 ≤ R
2
≤ 100% Always.
2
is a measure of the strength of linear
association between X and Y.
2
gives the amount (percent) of variation in
response (Y) that is explained by the explanatory
(independent) variable (X).
2
gives is the proportional reduction in error by
using the linear prediction equation in stead of the
alternative of using the sample mean as a predictor
of Y.
2
does not depend on units of measurement of X
or Y and it is itself unitless.
9.5 Inferences for slope and Correlation
1
Here TSS =Total sum of squares =
2
1
n
i
i
(Y Y )
and SSE = Sum of squared error =
2
1
n
i i
i
ˆ
(Y Y )
These are given in the ANOVA table.
( n 2 )
b
T ~ t
SE( b )
Here
2
1
b
n
i
i
SSE /( n )
SE( b )
IF Ha: 0 THEN p-value = 2×P(T ≥ | T
cal
IF Ha: < THEN p-value = P(T ≤ T
cal
IF Ha: > 0 THEN p-value = P(T ≥ T
cal
The calculated value of the test statistic and the p-value
(for a two-sided alternative are given in the computer
output).
Confidence Interval for :
The general formula we saw before applies here
CI for = (estimate of ME) with ME = t × SE(b)
Here estimate of is b and
SE(b) =
2
1
b n
i
i
SSE /( n )
SE( b )
Interpretation of CI for :
We are 95% confident that the true slope, , is
some number in the interval (– 0.171, – 0.143).
Observe that since this interval does not contain
zero we will reject the null hypothesis Ho: = 0 at
5% level of significance.
Furthermore, since both ends of the confidence
interval are negative, we have evidence to conclude
that the true slope is negative.
That is, the observed data give evidence of a
decreasing linear relation between the engine
power and mileage of cars.
Computer Output:
Until now we looked at parts of the SPSS output. Here is
the complete output. There are 4 or 5 panels in the output.
Panel 1:
Variables Entered/Removed(b)
Model
Variables
Entered
Variables
Removed Method
1 Horsepower
(a)
. Enter
a All requested variables entered.
b Dependent Variable: Miles per Gallon
This is the first panel of SPSS. It will be useful in the next
two Chapters.
Panel 2:
Model Summary(b)
Model R R Square
Adjusted R
Square
Std. Error of
the Estimate
1 .771(a) .595 .594 4.
a Predictors: (Constant), Horsepower
b Dependent Variable: Miles per Gallon
In this panel be careful with R! It is not equal to the
correlation coefficient when the slope is negative!!!