The Bucharest University of Economic Studies Bucharest Business School Romanian - French INDE MBA Program
The Bucharest University of Economic Studies Bucharest Business School Romanian - French INDE MBA Program
2
The Model
y 0 1x
y = dependent variable b0 and b1 are unknown population
x = independent variable y parameters, therefore are estimated
from the data.
b0 = y-intercept
b1 = slope of the line
Rise
e = error variable b1 = Rise/Run
b0 Run
x
3
Estimating the Coefficients
5
The Least Squares
(Regression) Line
Sum of squared differences = (2 - 1)2 + (4 - 2)2 + (1.5 - 3)2 + (3.2 - 4)2 = 6.89
Sum of squared differences = (2 -2.5)2 + (4 - 2.5)2 + (1.5 - 2.5)2 + (3.2 - 2.5)2 = 3.99
(2,4)
Let us compare two lines
4
w The second line is horizontal
3 w (4,3.2)
2.5
2
(1,2) w
w (3,1.5)
1 The smaller the sum of
squared differences
the better the fit of the
1 2 3 4
line to the data.
6
The Estimated Coefficients
To calculate the estimates of the line The regression equation that estimates
coefficients, that minimize the differences the equation of the first order linear model
between the data points and the line, use is:
the formulas:
cov( X , Y )
b1 ŷ b 0 b1x
s 2x
b 0 y b1 x
7
The Simple Linear Regression Line
43,528,690
n 1
x
10
The Simple Linear Regression
Line
SUMMARY OUTPUT
Regression Statistics
Multiple R 0.8063
R Square 0.6501
Adjusted R Square
0.6466
Standard Error 303.1
Observations 100 yˆ 17,067 .0623x
ANOVA
df SS MS F Significance F
Regression 1 16734111 16734111 182.11 0.0000
Residual 98 9005450 91892
Total 99 25739561
11
Interpreting the Linear
Regression -Equation
17067 Odometer Line Fit Plot
16000
15000
Price
14000
0 No data 13000
Odometer
yˆ 17,067 .0623x
b0 + b1x1 m1
From the
From the first
first three
three assumptions
assumptions we we have:
have:
yy isis normally
normally distributed
distributed with
with mean
mean x1 x2 x3
E(y) == bb00 ++ bb11x,
E(y) x, and
and aa constant
constant standard
standard
deviation ssee
deviation
14
Assessing the Model
The least squares method will produces
a regression line whether or not there
are linear relationship between x and y.
Consequently, it is important to assess
how well the linear model fits the data.
Several methods are used to assess
the model. All are based on the sum of
squares for errors, SSE.
15
Sum of Squares for Errors
This is the sum of differences between the
points and the regression line.
It can serve as a measure of how well the
line fits the data. SSE is defined by
n
SSE i 1
( y i ŷ i ) 2 .
– A shortcut formula
cov( X , Y )
SSE (n 1)s 2Y
s 2x
16
Standard Error of Estimate
The mean error is equal to zero.
If se is small the errors tend to be close to
zero (close to the mean error). Then, the
model fits the data well.
Therefore, we can, use se as a measure of
the suitability of using a linear model.
An estimator of se is given by se
259,996
n 1
2
cov( X , Y ) ( 2,712,511)
SSE (n 1)s 2Y 2
99(259,996) 9,005,450
sx 43,528,690
SSE 9,005,450 It is hard to assess the model based
s 303.13 on se even when compared with the
n2 98
mean value of y.
s 303.1 y 14,823 18
Testing the slope
When no linear relationship exists between
two variables, the regression line should be
horizontal.
q q
q
q q q
q q q
q q q q q
q q q q
qq qq
q qq
q q
q q q q
q q q
q q q q
q q q q
q qq qq qq qq q qq qq q q q q q qq
qqq
q q q q q q
qq qq q q qq q q q q q q q q
q q
q qq q q qq q q q q q qq q q q q q q
20
Testing the Slope,
Example
Example
Test to determine whether there is
enough evidence to infer that there is a
linear relationship between the car
auction price and the odometer reading
for all three-year-old Tauruses, in
Example 18.2.
Use a = 5%.
21
Testing the Slope,
Example
Solving by hand
To compute “t” we need the values of b1 and sb1.
b1 .0623
s 303.1
sb1 .00462
(n 1) s x2 (99)( 43,528,690)
b1 1 .0623 0
t 13.49
sb1 .00462
23
Coefficient of determination
To measure the strength of the linear
relationship we use the coefficient of
determination.
R2
cov(X , Y ) 2
2
or R 1
SSE
s 2x s 2y (y i y )2
24
Coefficient of determination
25
Coefficient of determination
y2
Two data points (x1,y1) and (x2,y2)
of a certain sample are shown.
x1 x2
Total variation in y = Variation explained by the + Unexplained variation (error)
regression line
(y1 y )2 (y 2 y)2 ( ŷ 1 y ) 2 ( ŷ 2 y ) 2 ( y 1 ŷ 1 ) 2 ( y 2 ŷ 2 ) 2 26
Coefficient of determination
• R2 measures the proportion of the variation in y
that is explained by the variation in x.
2
R 1
SSE
( y i y ) 2 SSE
SSR
(y i y ) 2
(y y)
i
2
(y i y ) 2
28
Coefficient of determination
– Using the computer
From the regression output we have
SUMMARY OUTPUT
Regression Statistics
Multiple R 0.8063 65% of the variation in the auction
R Square 0.6501 selling price is explained by the
Adjusted R Square
0.6466
Standard Error 303.1
variation in odometer reading. The
Observations 100 rest (35%) remains unexplained by
this model.
ANOVA
df SS MS F Significance F
Regression 1 16734111 16734111 182.11 0.0000
Residual 98 9005450 91892
Total 99 25739561
SUMMARY OUTPUT
32
Point Prediction
• Example
• Predict the selling price of a three-year-old
Taurus with 40,000 miles on the odometer
ŷ t 2 s 1 ŷ t 2 s
n (n 1)s x 2
n (n 1) s 2x
34
Interval Estimates,
Example
Example - continued
Provide an interval estimate for the bidding
price on a Ford Taurus with 40,000 miles
on the odometer.
Two types of predictions are required:
A prediction for a specific car
An estimate for the average price per car
35
Interval Estimates,
Example
• Solution
– A prediction interval provides the price estimate for a
single car:
1 ( x g x)
2
ŷ t 2 s 1
n (n 1)s 2x
t.025,98
Approximately
1 (40,000 36,009) 2
[17,067 .0623(40000)] 1.984(303.1) 1 14,575 605
100 (100 1)43,528,690
36
Interval Estimates,
Example
Solution – continued
A confidence interval provides the estimate
of the mean price per car for a Ford Taurus
with 40,000 miles reading on the odometer.
1 ( x g x)2
ŷ t =2 s
The confidence interval (95%)
n
( x i x)2
1 ( 40,000 36,009) 2
[17,067 .0623( 40000)] 1.984(303.1) 14,575 70
100 (100 1) 43,528,690
37
The effect of the given xg on
the length of the interval
As xg moves away from x the interval
becomes longer. That is, the shortest
interval isŷ found
b 0 b1xat
g
x.
1 ( x g x)
2
ŷ t 2 s
n (n 1)s 2x
38
The effect of the given xg on
the length of the interval
As xg moves away from x the interval
becomes longer. That is, the shortest
interval isŷ found
b 0 b1xat
g
x.
1 ( x g x)
2
ŷ t 2 s
n (n 1)s 2x
ŷ( x g x 1)
ŷ( x g x 1) 1 12
ŷ t 2 s
n (n 1)s 2x
x 1 x 1
x
( x 1) x 1 ( x 1) x 1
39
The effect of the given xg on
the length of the interval
As xg moves away from x the interval becomes
longer. That is, the shortest interval is found at x.
ŷ b 0 b1x g
1 ( x g x)
2
ŷ t 2 s
n (n 1) s 2x
1 12
ŷ t 2 s
n (n 1)s 2x
1 22
x2
x
x2 ŷ t 2 s
n (n 1)s 2x
( x 2) x 2 ( x 2) x 2
40
Coefficient of Correlation
42
Testing the coefficient of
correlation
When no linear relationship exist between the
two variables, r = 0.
The hypotheses are:
n2
H0: r = 0 tr
1 r 2
H1: r ¹ 0
where r is the sample
The test statistic is: coefficient of correlation
The statistic is Student t cov(x, y )
calculated by r
distributed with d.f. = n - 2, sx s y
provided the variables
are bivariate normally
distributed.
43
Testing the Coefficient of
correlation
Foreign Index Funds (Index)
A certain investor prefers the investment in
an index mutual funds constructed by
buying a wide assortment of stocks.
The investor decides to avoid the
investment in a Japanese index fund if it is
strongly correlated with an American index
fund that he owns.
From the data shown in Index.xls should
he avoid the investment in the Japanese
index fund?
44
Testing the Coefficient of
correlation
Foreign Index Funds
A certain investor prefers the investment in
an index mutual funds constructed by
buying a wide assortment of stocks.
The investor decides to avoid the
investment in a Japanese index fund if it is
strongly correlated with an American index
fund that he owns.
From the data shown in Index.xls should
he avoid the investment in the Japanese
index fund?
45
Correlation,
Example
Solution
Problem objective: Analyze relationship
between two interval variables.
The two variables are observational (the
return for each fund was not controlled).
We are interested in whether there is a
linear relationship between the two
variables, thus, we need to test the
coefficient of correlation
46
Correlation,
Example
Solution – continued
The value of the t statistic is
The hypotheses
n2
H0: r = 0 t r 4.26
1 r 2
48
Spearman Rank Correlation
Coefficient
The Spearman rank test is a nonparametric
procedure.
The procedure is used to test linear
relationships between two variables when the
bivariate distribution is nonnormal.
Bivariate nonnormal distribution may occur
when
at least one variable is ordinal, or
both variables are interval but at least one variable
is not normal.
49
Spearman Rank Correlation
Coefficient
The hypotheses are:
H0: rs = 0
H1: rs ¹ 0
The test statistic is cov(a, b)
rs
s a sb
– Solving by hand
• Rank each variable separately.
• Calculate sa = 5.92; sb =5.50; cov(a,b) = 12.34
• Thus rs = cov(a,b)/[sasb] = .379.
• The critical value for a = .05 and n = 20 is .450. 54
Spearman Rank Correlation
Coefficient,
Example
Conclusion:
Conclusion:
Do not
Do not reject
reject thethe null
null hypothesis.
hypothesis. At At 5%
5% significance
significance
level there
level there isis insufficient
insufficient evidence
evidence toto infer
infer that
that the
the
two variables
two variables are are related
related toto one
one another.
another.
55
Spearman Rank Correlation
Coefficient,
Example
Excel Solution
56
Regression Diagnostics - I
The three conditions required for the
validity of the regression analysis are:
the error variable is normally distributed.
the error variance is constant for all values
of x.
The errors are independent of each other.
How can we diagnose violations of
these conditions?
57
Residual Analysis
Examining the residuals (or
standardized residuals), help detect
violations of the required conditions.
Example – continued:
Nonnormality.
Use Excel to obtain the standardized residual
histogram.
Examine the histogram and look for a bell
shaped. diagram with a mean close to zero.
58
Residual Analysis
ObservationPredicted Price Residuals Standard Residuals
1 14736.91 -100.91 -0.33
2 14277.65 -155.65 -0.52
3 14210.66 -194.66 -0.65
4 15143.59 446.41 1.48
5 15091.05 476.95 1.58
A Partial list of
For each residual we calculate Standard residuals
the standard deviation as follows:
s ri s 1 hi where Standardized residual ‘i’ =
1 ( x i x) 2 Residual ‘i’
hi Standard deviation
n (n 1)s 2x
59
Residual Analysis
Standardized residuals
40
30
20
10
0
-2 -1 0 1 2 More
60
Heteroscedasticity
When the requirement of a constant variance is
violated we have a condition of heteroscedasticity.
Diagnose heteroscedasticity by plotting the residual
against the predicted y. +
^y
++
Residual
+
+ + + ++
+
+ + + ++ + +
+ + + +
+ + + ++ +
+ + + + y^
+ + ++ +
+ + +
+ + ++
+ + ++
500
Residuals
0
13500 14000 14500 15000 15500 16000
-500
-1000
Predicted Price
62
Non Independence of Error
Variables
A time series is constituted if data were
collected over time.
Examining the residuals over time, no
pattern should be observed if the errors are
independent.
When a pattern is detected, the errors are
said to be autocorrelated.
Autocorrelation can be detected by
graphing the residuals against time.
63
Non Independence of Error Variables
Patterns in the appearance of the residuals over time indicates
that autocorrelation exists.
Residual Residual
+
+ ++
+
+ + +
+ + +
0 + 0 + +
+ Time Time
+ + + + + +
+
+
+ ++ +
+
Note the runs of positive residuals, Note the oscillating behavior of the
replaced by runs of negative residuals residuals around zero.
64
Outliers
An outlier is an observation that is unusually
small or large.
Several possibilities need to be investigated
when an outlier is observed:
There was an error in recording the value.
The point does not belong in the sample.
The observation is valid.
Identify outliers from the scatter diagram.
It is customary to suspect an observation is an
outlier if its |standard residual| > 2
65
An outlier An influential observation
+++++++++++
+ +
+ … but, some outliers
+ +
+ +
may be very influential
+
+ + + +
+
+ +
+
66
Procedure for Regression
Diagnostics
Develop a model that has a theoretical basis.
Gather data for the two variables in the model.
Draw the scatter diagram to determine whether a
linear model appears to be appropriate.
Determine the regression equation.
Check the required conditions for the errors.
Check the existence of outliers and influential
observations
Assess the model fit.
If the model fits the data, use the regression
equation. 67