Lecture Week 13 - Regression
Lecture Week 13 - Regression
Least squares criterion: The best regression line is the one that produces
the smallest sum of squared errors of prediction.
e = 0 ∑e2=minimum
The regression line provides the best prediction of Y values from known X
values, but it is rare that the observed Y is exactly as is predicted (this only
Lecture Week 13 happens when r=+/-1).
Regression
Ŷ = Y only when r = ±1
1 2
( y − y)
0
2
-2
-4
sy =
-6
-8 N −1
0 1 2 3 4 5 6 7 8 9 10 11
3 7
8
6
4
2
0
-2
-4
• Using the same logic that we used for calculating Sy, we can -6
-8
Y −Y
n−2
6
4
r =0 2
0
Y = 0.6 -2
S Y = 4.30
0 1 2 3 4 5 6 7 8 9 10 11
the standard deviation of y predicted from x
8 10
8 10
1
2024-04-05
X
12 13
12 13
14 15
16 17
2
2024-04-05
18 19
18 19
20 21
yˆ = b0 + b1 x1 + b2 x2 + b3 x3 + bk xk
Remember… Calculations
• Best if each IV (x) is strongly correlated with DV (y) but uncorrelated • How do we calculate all those b’s?
with other IVs • It’s complicated to do by hand – use a computer!!
• Identify lowest number of IVs that will predict DV
• Each IV explains only an independent component of variance in DV • But some concepts are familiar
• Which IVs are in the model will influence how useful each IV is in the model –
shared variance is key in MR
22 23
22 23
3
2024-04-05
SSreg ത 2
(𝑦ො − 𝑦) Test F for significance
Signal we’re
• The portion of the variance in Y that is explained by all the predictors interested in
evaluating
• The portion of variance in y that is related to changes in x Variability in y that is explained by x
• This is the difference between our predicted y values and the mean of y 𝑀𝑆𝑟𝑒𝑔𝑟𝑒𝑠𝑠𝑖𝑜𝑛
𝐹=
• since 𝑦ത is best prediction of any y value in the absence of any useful IVs 𝑀𝑆𝑟𝑒𝑠𝑖𝑑𝑢𝑎𝑙
Noise we’re not
interested in
24
24 25
We’ll see if we can predict Performance on Comprehensive Exams from these three predictors
26 27
26 27
Analysis
28 29
28 29
4
2024-04-05
30 31
30 31
MS regression
F=
MS residual
32 33
32 33
34 35
5
2024-04-05
yˆ = b0 + b1 x1 + b2 x2 + b3 x3
school
Grades in grad school .416 .646 .402 .644 .586 .381 2.622
a. Dependent Variable: Perf ormance on comprehensiv e exams
z yˆ = 1 z x1 + 2 z x 2 + 3 z x 3
36
36 37
Another example
• University admissions officer trying to predict the future grades of
applicants
• use three variables (High School GPA, SAT, and Quality of letters of
recommendation) to predict university GPA.
• The regression equation for these data is:
𝑦=
ො 0.3764 X1+0.0012 X2 +0.0227X3 -0.1533
38 39
38 39
Correlations
Correlati ons
Regression analysis
Quality of
letters of Correlation between all predictors and Y.
Univ ersity Highschool recomme How much variance
GPA GPA SAT ndation
Not typically the focus of MR. Will always be in University GPA is
Univ ersity GPA Pearson Correlation 1 .264** -.419** .350** positive (b tells us about direction of explained by our 3
Sig. (2-tailed) .008 .000 .000 relationship between Y and each X). predictors
N 100 100 100 99
Highschool GPA Pearson Correlation .264** 1 .269** .627**
Model Summary
Sig. (2-tailed) .008 .007 .000
N 100 100 100 99 Adjusted St d. Error of
SAT Pearson Correlation -.419** .269** 1 .218* Model R R Square R Square the Estimate
Sig. (2-tailed) .000 .007 .030 1 .634a .402 .384 84.960 Standard deviation
N 100 100 100 99 a. Predictors: (Constant), Quality of letters of of the residuals
Quality of lett ers of Pearson Correlation .350** .627** .218* 1 recommendation, SAT, Highschool GPA (the difference
recommendation Sig. (2-tailed) .000 .000 .030 between predicted
N 99 99 99 99 How much variance Y and observed Y
**. Correlation is signif icant at the 0.01 lev el (2-tailed). in University GPA is scores)
*. Correlation is signif icant at the 0.05 lev el (2-tailed).
explained by our 3
predictors
40 41
40 41
6
2024-04-05
Coeffici entsa
MSerror . A measure of
the difference Unstandardized Standardized
between observed Coef f icients Coef f icients
and predicted scores. Model B Std. Error Beta t Sig.
1 (Constant) 72.695 43.203 1.683 .096
Square root of this =
Highschool GPA 27.901 14.944 .193 1.867 .065
ANOVAb
SEestimate .
SAT -.247 .037 -.547 -6.628 .000
Sum of Quality of lett ers of
25.097 7.343 .349 3.418 .001
Model Squares df Mean Square F Sig. recommendation
1 Regression 461685.1 3 153895.031 21.321 .000a a. Dependent Variable: Univ ersit y GPA
Residual 685722.1 95 7218.127 Measure of relationship between University
Total 1147407 98 GPA and Highschool GPA when SAT and Letters
a. Predictors: (Const ant), Qualit y of let ters of recommendation, SAT, Highschool GPA of Rec. are held constant.
b. Dependent Variable: Univ ersity GPA
aka measure of this relationship with the
effects of the other two variables removed
from the relationship.
42 43
Model Summary
Adjusted St d. Error of
• Each IV is evaluated in terms of what it adds to the prediction of Y at the point Unstandardized St andardized
Coef f icients Coef f icients
it’s entered
Model B St d. Error Beta t Sig.
• Stepwise (Statistical) 1 (Constant) -66.291 30.972 -2.140 .035
Highschool GPA 38.236 14.089 .264 2.714 .008
• Controversial – based only on the data a. Dependent Variable: Univ ersity GPA
• Forward, backward, stepwise
Is the model significant?
Does HS-GPA contribute significantly to our prediction of U-GPA?
44 How much variance in U-GPA is explained by HS-GPA? 45
44 45
Model Summary
Adjusted St d. Error of
Model R R Square R Square the Estimate
1 .573a .329 .315 89.552 What variables go in the regression equation?
a. Predictors: (Constant), SAT, Highschool GPA
ANOVAb
46 47
7
2024-04-05
Correlated predictors
• Remember, we want to have predictors that are highly correlated
with the criterion but not with one another. On its own, IV1 would explain
a+b variance in Y.
• The contribution of each variable to the regression model really On its own IV2 would explain
IV1
represents how much variance it explains in the model that can’t be a c+b variance in Y.
explained by other variables in the model. DV With both variables in the
• If predictors are highly correlated with one another, knowing something b model, the importance of
about one tells you something about the other. each will decrease.
c
• so variance in Y explained by one predictor can be explained by another predictor.
IV2 Further, the apparent
importance of each will
depend on which was
entered first.
48 49
48 49
Adjusted St d. Error of
Model R R Square R Square the Estimate
Can look at p values to
1 .632a .400 .381 .593 see if a given variable
a. Predictors: (Constant), Quality of letters of contributes significantly
recommendation, SAT, Highschool GPA
to the model.
ANOVAb
Sum of
Model Squares df Mean Square F Sig.
1 Regression 22.211 3 7.404 21.085 .000a
Residual 33.358 95 .351
Total 55.569 98
a. Predictors: (Const ant), Qualit y of let ters of recommendation, SAT, Highschool GPA
b. Dependent Variable: Univ ersity GPA
Coeffici entsa
Unstandardized Standardized
Coef f icients Coef f icients
Model B Std. Error Beta t Sig.
1 (Constant) -.153 .325 -.472 .638
Highschool GPA .376 .115 .363 3.277 .001
SAT .001 .000 .356 4.023 .000
Quality of lett ers of
.023 .051 .045 .443 .659
recommendation
a. Dependent Variable: Univ ersit y GPA
50 51
50 51
Variabl es Entered/Removedb
Variables Variables
Model Ent ered Remov ed Method
1
2
Highschoo
l GPA
SATa
a .
.
Ent er
Ent er
Cheating…
3 Quality of
letters of
. Ent er
recommen
dation
a
• When doing MR, we want to think about the theory and what
a. All requested v ariables entered.
b. Dependent Variable: Univ ersity GPA Look also at SEest! variables make sense to include in the analysis.
• We don’t want to just try entering variables in all different orders and
see which model is best.
Model Summary
52 53
52 53
8
2024-04-05
54 58
54 58
β coefficents
• Standardized (in units of standard deviation)
• Show the change in Y that’s associated with a one-unit change in X - but now
the changes are in standard deviations of both variables.
• how strongly each predictor variable influences Y
• Use these to compare the relative effects of variables in a regression model.
Both b-coefficients and beta-coefficients can be interpreted as
59 60
controlling for the effects of other variables.
59 60
• With more than one predictor variable, we can’t compare the contribution of
each predictor variable by simply comparing the correlation coefficients (b’s).
• The beta coefficient allows such comparisons
61 63
61 63
9
2024-04-05
Beta coefficients
• A negative beta means means your two variables (X,Y) are negatively correlated.
Don’t ignore the sign!
• BUT if the beta coefficient seems to change sign as you add or subtract other X
variables, you may have multicollinearity.
• Normally the beta coefficient should not change sign as you add more independent
variables.
64
64
10