Sta 3
Sta 3
1/34 2/34
3.5
2.5
2
y
1.5
0.5
0
0 2 4 6 8 10
x
3/34 4/34
Prediction problems Input/output problems
5/34 6/34
7/34 8/34
Simple linear model Linear regression function
The simplest regression model is is the linear model The function f (x) = E [y|x] is also known as regression function.
y = β0 + β1 x + w
y
where
◮ x ∈ R is the regressor (or independent) variable,
◮ y ∈ R is the measured response (or dependent) variable, 1
0
0
1
E[y|x 1] 0
1
0
1 E[y|x 2]
◮ β0 is the intercept, β1 is the slope regression 0
1
function
◮ E [w] = 0 where w is the model error
This implies that
E [y|x] = f (x) = β0 + β1 x
Var [y|x] = Var [w] x1 x2 x
9/34 10/34
11/34 12/34
Model estimation Least squares formulation
13/34 14/34
15/34 16/34
Univariate least-squares solution Properties of the least-squares estimators
If the dependency underlying the data is P
linear then the estimators
It can be shown that the least-squares solution is
are unbiased. Since x is nonrandom and N i =1 (xi − x̄) = 0
Sxy
β̂1 = β̂0 = ȳ − β̂1 x̄ N
Sxx Sxy X (xi − x̄)E [yi ]
EDN [β̂ 1 ] = EDN =
Sxx Sxx
where PN PN
i =1
i =1 xi i =1 yi
N N
!
x̄ = , ȳ = 1 X X β1 Sxx
N N = [(xi − x̄)β0 ] + [(xi − x̄)β1 xi ] = = β1
Sxx Sxx
i =1 i =1
and
N
Also it can be shown that
X
Sxy = (xi − x̄)yi h i σ2
Var β̂ 1 = w
i =1 Sxx
N N
X X E [β̂ 0 ] = β0
Sxx = (xi − x̄)2 = (xi − x̄)xi
x̄ 2
i =1 i =1
h i
2 1
Var β̂ 0 = σw +
N Sxx
17/34 18/34
19/34 20/34
Variance of the response Multiple linear dependency
◮ Since β̂0 = ȳ − β̂1 x̄ ◮ Consider a linear relation between an independent variable
^
y = β̂ 0 + β̂ 1 x = ȳ − β̂ 1 x̄ + β̂ 1 x = ȳ + β̂ 1 (x − x̄) x ∈ X ⊂ Rn and a dependent random variable y ∈ Y ⊂ R
The multiple linear regression model with n = 2 The multiple linear regression model
Consider N observations DN = {hxi , yi i : i = 1, . . . , N}, where
xi = (1, xi 1 , . . . , xin ), generated according to the previous model.
We suppose that the following multiple linear relation holds
Y = Xβ + W
◮ R script Linear/bv_mult.R.
27/34 28/34
Variance of the prediction Generalization error of the linear model
◮ The prediction ^
y for a generic input value x = x0 is unbiased ◮ The linear predictor
ŷ = x T β̂
y|x0 ] = x0T β
E [^
has been estimated by using the training dataset
◮ The variance of the prediction ^
y for a generic input value DN = {hxi , yi i : i = 1, . . . , N}. Then β̂ is a r.v.
x = x0 is given by ◮ Now we want to use it to predict for a test input x the future
x0 (X T X )−1 x0
2 T
y|x0 ] = σw
Var[^ output y(x).
◮ The test output y(x) is independent of the training set DN .
◮ Assuming a normal error w, the 100(1 − α)% confidence ◮ Which precision can we expect from ŷ (xi ) = xiT β̂ on average?
y|x = x0 ] is given by
bound for the regression value E [^ ◮ A measure of error is the MSE
q
ŷ(x0 ) ± tα/2,N−p σ̂w x0T (X T X )−1 x0 MSE(x) = EDN ,y [(y(x) − x T β̂)2 ] = σw
2
+ EDN [(x T β − x T β̂)2 ]
where tα/2,N−p is the upper α/2 percent point of the where y(xi ) is independent of DN and the integrated version
t-distribution with N − p degrees of freedom and the quantity
Z
q MISE = MSE(x)p(x)dx
σ̂w x0T (X T X )−1 x0 is the standard error of prediction for X
multiple regression. ◮ How can we estimate this quantity?
29/34 30/34
1 2
derivation in the handbook derivation in the handbook
31/34 32/34
MISE error The PSE and the FPE
33/34 34/34