Professional Documents
Culture Documents
Jinhan Xie
Winter, 2023
Outline
Vectors
x=x ⇒ cx = cx.
inner product:
n
X
hx, yi := xi yi = hy, xi .
i=1
length, or norm:
p q
kxk := hx, xi = x12 + x22 + · · · + xn2 .
hcx, yi = c hx, yi ;
p q p
kcxk = hcx, cxi = c2 hx, xi = |c| hx, xi = |c|kxk.
kx + yk ≤ kxk + kyk.
Matrix
Matrix A, of dimension m × n, is just a table of (real) numbers.
A1,1 A1,2 · · · A1,n
A2,1 A2,2 · · · A2,n
A= . .. .
.. ..
.. . . .
Am,1 Am,2 · · · Am,n
Y = β0 + β1 X + ε,
y = βˆ0 + βˆ1 x.
Let (yi , xi ) be the i-th observation and ŷi = βˆ0 + βˆ1 xi , we call ei = yi − ŷi
the ith residual.
To estimate the parameters, we minimized the residual sums of squares
(RSS),
X X 2
RSS = e2 = yi − βˆ0 − βˆ1 xi , .
i
i i
P P
Denote ȳ = i yi /n and x̄ = i xi /n. The minimized values are
P pP !
− ȳ)(xi − x̄) (y − 2
i (y
Pi
i ȳ)
βˆ1 = 2
= r pP i ,
i (xi − x̄)
2
i (xi − x̄)
Example
●
●
● ● ● ●
25
●
● ●
● ● ●
●
● ● ●
● ● ●
● ●
● ●
●
● ● ● ●
20
● ● ●
● ● ● ●
● ● ●
● ● ● ●
● ● ●
● ● ●
● ● ●
● ● ● ● ●
● ●
● ●●
● ● ● ● ●●
● ●● ● ●
●
15
● ●
Sales
● ● ● ● ●●
●● ● ● ●
● ●
● ●
● ● ● ●
● ● ● ●
● ● ●● ● ● ●
● ● ● ● ●
● ● ● ●
● ●
● ●● ● ● ●
● ● ● ●
● ● ●
●●
● ● ● ●
●
●● ● ● ●●
● ●● ● ● ●
● ● ●
●
10
●● ● ●
● ● ● ●●● ●●
●
●
● ● ● ●
● ●● ● ● ● ●
●
● ●
● ●
●● ●
● ●●
● ●●
●● ●●
● ●
5
TV
Advertising data: the least square fit for the regression of sales and TV.
Each grey line segment represents an error, and the fit makes a
compromise by averaging their squares.
In this case a linear fit captures the essence of the relationship, although
it is somewhat deficient in the left of the plot.
Jinhan Xie (University of Alberta) Lecture 3 LR I Winter, 2023 10/20
Simple Linear Regression
Estimation and Inference
Summary and Remark
Interval Estimates
A point estimate gives a single number, but does not give information about
the precision and reliability of estimation. For example, given βˆ1 = 1.2231,
we have no information about how close it might be to β1 .
where σ 2 = Var(ε).
A 95% confidence interval is defined as a range of values such that with
95% probability, the range will contain the true unknown value of the
parameter.
It has the form
βˆ1 ± 2 · SE(β̂1 ).
For the advertising data, the 95% confidence interval for β1 is
[0.042, 0.053], which means, there is approximately 95% chance this
interval contains the true value of β1 (under a scenario where we got
repeated samples like the present sample).
Jinhan Xie (University of Alberta) Lecture 3 LR I Winter, 2023 12/20
Simple Linear Regression
Estimation and Inference
Summary and Remark
Hypothesis testing
Hypothesis testing
H0 : β1 = 0 versus HA : β1 6= 0,
Four possibilities
Hypothesis testing
To test the null hypothesis, we compute a t-statistics,
β̂1 − 0
t= .
SE βˆ1
Measure of fit
Measure of fit
R code
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.032594 0.457843 15.36 <2e-16 ***
TV 0.047537 0.002691 17.67 <2e-16 ***
---
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1