Professional Documents
Culture Documents
Sahadeb Sarkar
Operations Management Group, IIM Calcutta
Readings
Regression Based Business Forecasting:
Covariance & Correlation Coefficient (Sec 3.5,
5.2), Simple Linear Regression (Sec 13.1-13.6),
Multiple Linear Regression (Sec 14.1, 14.2, 14.6
(Dummy Var Reg), 15.1 (Polynomial Reg), 15.2)
4
Simple Linear Regression Model
Y Yi a bX i ei
Observed Value
of Y for Xi
ei Slope = b
Predicted Value Random Error
of Y for Xi
for this Xi value
Intercept = a
Xi X
Simple Linear Regression: Assumptions
• The relationship between X
Y
Assumptions of the Simple
Linear Regression Model
and Y is a straight-line
relationship.
• The values of the
independent variable X are
assumed fixed (not random);
E[Y]=0 + 1 X
the only randomness in the
values of Y comes from the
error term i.
• The errors ei are normally
distributed with mean 0 and
variance 2. The errors are at Identical normal
distributions of
least uncorrelated (not errors, all centered
on the regression
related) in successive line.
observations. That is: ei ~
N(0,2) X
Suppose Y=Sales and X=AE (Adv Exp); we assume that for a given AE value the
conditional distribution of possible sales values is normal and expected (average)
Sales change as a linear function of AE but the variation in Sales remain unchanged.
Trent
Trent is a retail operations company that owns and
manages a number of retail chains in India. Established in
1998, Trent runs lifestyle chain Westside, one of India’s
largest and fastest growing chain of lifestyle retail stores,
Star Bazaar, a hypermarket chain, Landmark, a books and
music chain, and Fashion Yatra, a complete family fashion
store.
7
Example: Data on Quarterly Advertising Expense (X) and
Quarterly Net Sales (Y) for Trent from Dec 2003 to Mar 2008.
Hold-Out or
Validation Sample,
set aside to check 8
prediction ability
Different Regression Models
Simple Linear Regression:
(1) Sales = a + b*AE, AE= Adv Exp
(2) Sales = a + b*PC, PC= Personnel Cost
Multiple Linear Regression:
(3) Sales = a + b1*AE + b2*PC
[Note 1: Adding (AE+PC) as a new predictor in the above model is not useful]
Polynomial Regression:
(4a) Sales = a + b1*PC + b2*(PC)2
(4b) Sales = a + b1*AE + b2*(AE)2
Dummy Variable Regression:
(5) Sales = a*1 + b*Time + c1*Q1+ c2*Q2+ c3*Q3, where Q1, Q2,Q3 are
indicator variables for quarters 1,2,3.
[ Note 2: a= a*1; Q1+Q2+Q3+Q4=1 Q4=1(Q1+Q2+Q3); adding Q4 in the above
model as a predictor is not useful when ‘constant term a’ and Q1, Q2,Q3 are present.]
9
Summary
11
130 12
120 Net sales 11
110 Adv Exp 10
100 9
Net Sales
Adv Exp
90 8
80 7
70 6
60 5
50 4
40 3
30 2
04
05
06
3
6
-0
-0
-0
-0
n-
n-
n-
ec
ec
ec
ec
Ju
Ju
Ju
D
12
Trent data: Correlation = 0.78
140
120
100
Net Sales
80
60
40
20
2 4 6 8 10 12
Adv Exp
13
Correlation = 0.97
140
120
100
Net Sales
80
60
40
20
2 3 4 Personnel
5 Cost 6 7 8
14
Measures of linear relationship:
(Sample) Covariance
1
Definition: Covariance = σ𝑛𝑖=1 𝑥𝑖 − 𝑥ҧ 𝑦𝑖 − 𝑦ത
𝑛−1
1 (σ𝑛 𝑛
𝑖=1 𝑥𝑖 )(σ𝑖=1 𝑦𝑖 )
Shortcut Formula: σ𝑛𝑖=1 𝑥𝑖 𝑦𝑖 −
𝑛−1 𝑛
15
Measures of linear relationship:
(Sample) Covariance
1
Covariance = σ𝑛𝑖=1 𝑥𝑖 − 𝑥ҧ 𝑦𝑖 − 𝑦ത
𝑛−1
16
Measure of linear relationship: (Sample) Correlation
1
σ𝑛 𝑥𝑖 −𝑥ҧ 𝑦𝑖 −𝑦ത Covariance(x,y)
𝑛−1 𝑖=1
𝑟= =
1 1 SD x SD(y)
σ𝑛 𝑥𝑖 −𝑥ҧ 2 σ𝑛 𝑦𝑖 −𝑦ത 2
𝑛−1 𝑖=1 𝑛−1 𝑖=1
(σ𝑛 𝑛
𝑖=1 𝑥𝑖 )(σ𝑖=1 𝑦𝑖 )
Note1: σ𝑛𝑖=1 𝑥𝑖 − 𝑥ҧ 𝑦𝑖 − 𝑦ത =σ𝑛𝑖=1 𝑥𝑖 𝑦𝑖 − 𝑛𝑥ҧ 𝑦ത = σ𝑛𝑖=1 𝑥𝑖 𝑦𝑖 −
𝑛
2
(σ𝑛 𝑛
𝑖=1 𝑥𝑖 )(σ𝑖=1 𝑥𝑖 ) (σ𝑛 𝑥)
Note2: σ𝑛𝑖=1 𝑥𝑖 − 𝑥ҧ 2
= σ𝑛𝑖=1 𝑥𝑖 − 𝑥ҧ 𝑥𝑖 − 𝑥ҧ =σ𝑛𝑖=1 𝑥𝑖 𝑥𝑖 − = σ𝑛𝑖=1 𝑥𝑖 2 − 𝑖=1𝑛 𝑖
𝑛
17
Measure of linear relationship: (Sample) Correlation
σ𝑛𝑖=1 𝑥𝑖 − 𝑥ҧ 𝑦𝑖 − 𝑦ത
𝑟=
σ𝑛𝑖=1 𝑥𝑖 − 𝑥ҧ 2 σ𝑛𝑖=1 𝑦𝑖 − 𝑦ത 2
(σ𝑛 𝑛
𝑖=1 𝑥𝑖 )(σ𝑖=1 𝑦𝑖 )
Note1: σ𝑛𝑖=1 𝑥𝑖 − 𝑥ҧ 𝑦𝑖 − 𝑦ത =σ𝑛𝑖=1 𝑥𝑖 𝑦𝑖 − 𝑛𝑥ҧ 𝑦ത = σ𝑛𝑖=1 𝑥𝑖 𝑦𝑖 − 𝑛
2
(σ𝑛 𝑛
𝑖=1 𝑥𝑖 )(σ𝑖=1 𝑥𝑖 ) (σ𝑛 𝑥)
Note2: σ𝑛𝑖=1 𝑥𝑖 − 𝑥ҧ 2
= σ𝑛𝑖=1 𝑥𝑖 − 𝑥ҧ 𝑥𝑖 − 𝑥ҧ =σ𝑛𝑖=1 𝑥𝑖 𝑥𝑖 − = σ𝑛𝑖=1 𝑥𝑖 2 − 𝑖=1𝑛 𝑖
𝑛
19
Calculation of r
20
Correlation Analysis for Trent Data
22
(Nearly) Zero Correlation
23
Interpretation of Correlation values
• Zero correlation does not mean no relationship [there
may be nonlinear relationship; correlation measures linear
relationship]
24
Example 1: Quarterly Advertising Expense (X) and
Quarterly Net Sales (Y) for Trent from Dec-03 to Mar-07.
Predict sales for Jun-07 quarter if (approx) 9.58 crores
earmarked for Adv Exp for Jun-07.
25
Simple linear regression
26
Minimize SSE = i(yi-a-bxi)2, w.r.t. a, b
Simple Linear Regression Model: Yi= (a*1 + b*Xi) + ei.
( x x )(y
i i y)
sy
b i 1
n
ry , x , where s y and s x are
sx
i
( x
i 1
x ) 2
a y b x
Predicted Value of y a bx y b (x x )
a y b x
Predicted Value of y a bx y b (x x )
29
Estimated Reg line (Trent data): Net Sales = 27.82 + 7.59
(Adv Exp);
(i) Interpretation of 𝑏 (b-hat), 𝑎ො (a-hat)??
(ii) For next quarter Jun-07, predicted net sales= 27.82 +
7.59*(9.58) = 100.56 crore (actual sales = 121.6)
30
Simple Linear Regression: Assumptions
• The relationship between X
Y
Assumptions of the Simple
Linear Regression Model
and Y is a straight-line
relationship.
• The values of the
independent variable X are
assumed fixed (not random);
E[Y]=0 + 1 X
the only randomness in the
values of Y comes from the
error term i.
• The errors ei are normally
distributed with mean 0 and
variance 2. The errors are at Identical normal
distributions of
least uncorrelated (not errors, all centered
on the regression
related) in successive line.
observations. That is: ei ~
N(0,2) X
Suppose Y=Sales and X=AE (Adv Exp); we assume that for a given AE value the
conditional distribution of possible sales values is normal and expected (average)
Sales change as a linear function of AE but the variation in Sales remain unchanged.
How Good is the Regression Fit?
• Total variation in y-values divided in two parts:
Y Yi a bX i ei
Observed Value
of Y for Xi
ei Slope = b
Predicted Value Random Error
of Y for Xi
for this Xi value
Intercept = a
Xi X
Measures of Variation
Y
Yi
SSE = (Yi - Yi )2 Y
_
SST = (Yi - Y)2
Yi _
_ SSR = (Yi - Y)2 _
Y Y
Xi X
R2 = proportion of variation in Y explained by variation
in explanatory variable(s) through regression relation
𝑆𝑆𝑅 𝑆𝑆𝐸
Definition: 𝑅2 = =1−( )
𝑆𝑆𝑇 𝑆𝑆𝑇
𝑆𝑆𝐸/(𝑛−𝑘−1)
Definition: 𝐴𝑑𝑗𝑢𝑠𝑡𝑒𝑑 𝑅2 = 1−
𝑆𝑆𝑇/(𝑛−1)
where k = number of non-constant predictors and ‘1’ refers to
presence of a constant predictor;
Note: R2 involves ratio of SSE (total amount of variation in errors) to TSS
(total amount of variation in response Y values);
Adjusted R2 involves ratio of SSE/(n-k-1) (i.e., ‘average’ amount of
variation in errors) to SST/(n-1) (i.e., ‘average’ amount of variation in
response Y values).
(𝑛−1)
Verify: 𝐴𝑑𝑗𝑢𝑠𝑡𝑒𝑑 𝑅2 = 1 − (1 − 𝑅2 ) ;
(𝑛−𝑘−1)
35
R2 (‘Coefficient of Determination’) & Adjusted R2
50
40
30
20
Res
10
0
-10 40 50 60 70 80 90 100 110 120
-20
-30
Pred
37
Simple Linear Regression: Assumptions
• The relationship between X
Y
Assumptions of the Simple
Linear Regression Model
and Y is a straight-line
relationship.
• The values of the
independent variable X are
assumed fixed (not random);
E[Y]=0 + 1 X
the only randomness in the
values of Y comes from the
error term i.
• The errors ei are normally
distributed with mean 0 and
variance 2. The errors are at Identical normal
distributions of
least uncorrelated (not errors, all centered
on the regression
related) in successive line.
observations. That is: ei ~
N(0,2) X
Suppose Y=Sales and X=AE (Adv Exp); we assume that for a given AE value the
conditional distribution of possible sales values is normal and expected (average)
Sales change as a linear function of AE but the variation in Sales remain unchanged.
Durbin Watson (DW) Statistic
• DW =
sum of squares of (residual – previous residual),
divided by
sum of squares of residuals.
• DW ≈ 2 * (1 – r), where r = correlation between
current residual and previous residual
• DW ≈ 2 indicates errors are serially uncorrelated
• 1.5 DW 2.5 may be acceptable (range of DW
is 0 to 4)
39
Durbin Watson (DW) Statistic
σ𝑛
𝑖=2 𝑒𝑖 −𝑒𝑖−1
2
• 𝐷𝑊 = σ𝑛 2
𝑖=1 𝑒𝑖
σ𝑛
𝑖=2 𝑒𝑖
2 σ𝑛
𝑖=2 𝑒𝑖−1
2 σ𝑛
𝑖=2 2𝑒𝑖 𝑒𝑖−1
= σ𝑛 2 + σ𝑛 2 − σ𝑛 2
𝑖=1 𝑒𝑖 𝑖=1 𝑒𝑖 𝑖=1 𝑒𝑖
σ𝑛
𝑖=2 𝑒𝑖 −𝑒ҧ (𝑒𝑖−1 −𝑒)
ҧ
≈ 1+1−2
σ𝑛
𝑖=1 𝑒𝑖 −𝑒ҧ 2 σ𝑛
𝑖=1 𝑒𝑖−1 −𝑒ҧ
2
40
Random Pattern, as shown in graph below,
indicates Regression Errors “Independent”
Suppose Y=Sales and X=AE (Adv Exp); we assume that for a given AE value the
conditional distribution of possible sales values is normal and expected (average)
Sales change as a linear function of AE but the variation in Sales remain unchanged.
Estimating Error Variance, 2, in
Simple Linear Regression: Yi = a + b*Xi
Building blocks of SSE are the residuals ei = (𝑌𝑖 − 𝑌𝑖 ), which satisfy two
restrictions; thus only (n-2) of the residuals can take values freely but the
remaining two can not. Hence the ‘degrees of freedom’ is (n-2) and we
divide by (n-2) to calculate ‘average’ of the squared errors in the definition
MSE to estimate 2. 44
How good is SLR of Net Sales on Adv Exp ?
47
Multiple Regression Equation With Two
Independent Variables
Two variable model
Y
Ŷ b0 b1X1 b 2 X 2
X2
X1
Residuals in Multiple Regression
ei = (Yi – Yi)
<
Yi
x2i
X2
x1i
The best fit equation is found
X1 by minimizing the sum of
squared errors, e2.
Multiple Linear Regression (MLR)
n
Minimize y i a b1x1i b 2 x 2i ... b k x ki
2
i 1
50
“Equations” to solve for estimating MLR
SSE n
2 yi a b1 x1i b2 x2i ... bk xki (1) 0
a i 1
SSE n
2 yi a b1 x1i b2 x2i ... bk xki ( x1i ) 0
b1 i 1
………
SSE n
2 yi a b1 x1i b2 x2i ... bk xki ( xki ) 0
bk i 1
51
Short-cut method for writing Equations to
solve for estimating MLR
• Model: Y=a*1 + b1*X1 + b2*X2+ …+ bk*Xk + error
53
Example (Trent Data):
54
Example (Trent): MLR Net Sales = -4.93 + 2.55 (Adv Exp)
+ 13.60 (Person. Cost), (Adj R2=0.97, DW=1.1). For June
2007, Predicted value = 144.42 crore (Actual = 121.6)
10.00
5.00
Res
0.00
40.00 60.00 80.00 100.00 120.00 140.00
-5.00
-10.00
Pred
55
Example (Trent Data): Try MLR of Net Sales on
Personnel Cost, PC^2 and Adv Exp. (Adj R2=.978,
DW=1.64, Pred=129) (Actual = 121.6)
Res
-2 30 50 70 90 110 130
-4
-6
-8
-10
Pred
56
Summary so far …
57
Regression using
“Dummy Predictors”
(used for a Qualitative Predictor Variable)
58
Trent Data: Line plot of Net Sales over Time
Dec-05
Dec-06
Sep-04
Mar-05
Jun-05
Sep-05
Mar-06
Sep-06
Mar-07
Jun-04
Jun-06
59
60
DVR Results (Trent Data)
Net sales = 30.66 + 6.57*Time; (Adj R2 = 0.94,
DW=1.86)
61
Polynomial Regression
• Data: (x1,y1), (x2,y2), …, (xn, yn)
• Minimize
n
SSE y i a b1x i b 2 x ... b k x
2
i
k 2
i
i 1
62
When Polynomial Regression ??
Y Y
x x
residuals
residuals
x x
Not Linear
Linear 63
Fitting Polynomials (in X) to Data
(Y=a + b1X + b2X2+ …+ bkXk + error)
64
Remember SLR on PC (Trent data): Net Sales = -
2.007+16.53 (Person. Cost); for next quarter, predicted net
sales= - 2.007+16.53 (9.19) =149.94 crore (Actual = 121.6)
SLR-PC(DW=1.67)
15.00
10.00
5.00
Res
0.00
40.00 60.00 80.00 100.00 120.00 140.00
-5.00
-10.00
-15.00
Pred
65
Try Quadratic Reg in PC (Trent data): Net Sales = -
44.12+34.47 (PC) - 1.73(PC2); for next quarter, predicted net
sales = - 44.12 +34.47 (9.19) - 1.73(9.19)2 =126.93 crore
(Actual = 121.6) Adj R2=0.94
10
0
Res
30 50 70 90 110 130
-5
-10
-15
Pred
66
Summary
Standard
Normal
(t with df = )
0
68
F Distribution
Let Y1 and Y2 be independent r.v.s having 2 distributions
with df=m1 and m2 respectively. Then (Y1/m1)/(Y2/m2) has F
dist with df=(m1,m2)
69