














































































Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!















































































List of Figures I
g(x)
(y − E[y|x])
E[y|x] − g(x))^2
Figure 1.1: Error in Euclidean Distance
Names:
Example: y = β 0 + β 1 X 1 + · · · + βpXp + ϵ = fθ(x) + ϵ θ = (β 0 , β 1 ,... , βp) ∈ Rp+^
So, taking in consideration Equation 1.1.2, we can proceed with fitting the model. To fit the model we need to find:
β^ ˆ = argminβ∈Rp+
∑^ n
i=
(yi − β 0 − β 1 Xi 1 − · · · − βpXip)^2 (1.2)
So we are looking for the parameters β that minimize the error.
Until now we have just created our model, now we can asses it real capabilities. We created our model with the idea of reducing the error of the training data , but we still not consider how will act in the real world. So to do that take in consideration this:
So after had fit the model on the trading data we can proceed with:
=⇒ Evaluate : E|x 0 [(y 0 − yˆ 0 )^2 ] = (f (x 0 ) − fˆ (x 0 ))^2 + Var(ϵ 0 )
So now we can compare the training error (Equation 1.3a) with the generalization error(Equation 1.3b):
Training Error =
n
∑^ n
i=
(yi − fˆ (xi))^2 (1.3a)
General Error = E|data[(y 0 − fˆ (x 0 ))^2 ] = E[(y 0 − fˆ (x 0 ))^2 ] (1.3b)
Complexity of the Model
Error
Training Error Generalization Error
Figure 1.2: Training Error vs. Generalization Error
Training error represents how well the model fits the training data and tends to decrease as the model becomes more complex because the model is optimizing its performance specifically for the training data. Generalization error measures how well the model performs on new, unseen data and is typically higher than training error because the model is being evaluated on data it hasn’t seen before, which may have different characteristics.In summary, Generalization error is a more reliable indicator of a model’s performance in practice because it assesses how well the model can generalize its learned patterns to new situations.
Proposition: E[(y 0 − fˆ (x 0 ))^2 ] = (f (x 0 ) − E[ fˆ (x 0 )])^2 + Var( fˆ (x 0 )) + Var(ϵ 0 )
Where the bias is (f (x 0 ) − E[ fˆ (x 0 )])^2 , variance is Var( fˆ (x 0 )) and the error is the Var(ϵ 0 ). Now in order to reduce the error we need to reduce the variance but doing that we probably will become bias, this means that our generalization error will increase. So we need to find a point of balance between bias and variance this problem is call Bias-Variance trade-off.
A high bias means the model is making simplistic assumptions about the underlying data and may
that errors have the same variance means that is homogeneous across all observation. But there’s also a more compact way to write this model as:
y = X β + ϵ (1.5)
Where X is know as n × p Design Matrix:
x 11 x 12... x 1 p xn 1 xn 2... xnp
= (x 1 , x 2 ,... , xp)
and
x⊤ 1 .. . x⊤ n
x 11 x 12... x 1 n x 21 x 22... x 2 n .. .
xp 1 xp 2... xpn
For this chapter we will assumed X FULL RANK p, meaning that all the columns are linearly indepen- dent.
Linearly Independent means that none of the variables can be explained by another variable or a combination of more variables. So we don’t have Multicollinearity.
We can also introduce a known parameter Xi 0 for all i:
y = X 0 + Xβ + ϵ
yi : Xi 0 + Xi 1 β 1 + · · · + Xipβp + ϵi
This new feature is call offset (absorbed in the design matrix, becomes just column + mean) when Xi 0 is assumed to be known. Corresponding parameter β 0 assumed to be =1 =⇒
y = X 0 · 1 + Xβ + ϵ
We can also to remove the offset Xi 0 by defining a new target variable as y˜i = yi − Xi 0 :
y ˜i = xi 1 β 1 + · · · + xipβp + ϵi with y˜i as the dependent variable
But in this case β 0 is going to be β 1 , and we have to recover (X′) by setting Xi 1 = 1 for all i. In this way we are centring the model.
y → y − ¯y xi → xi − ¯xi β 0 = ¯y − β 1 x¯ 1 − · · · − βp x¯p
There are different methods to estimate the parameters the first we are going to talk about is the Ordinary Least Square or OLS, where the objective is the minimization of the residual sum of squares with respect to β(OLS is less suitable for LMM.). Find β that minimizes the distance between what I observed (y) and what I would observe if there were no errors (Xβ):
β^ ˆOLS = arg min β ∥yi − x⊤ i β∥^2 = arg min β
∑n
i=
(yi − x⊤ i β)^2 (1.6)
where x⊤ i β is the i-th row of vector xi, i.e., x⊤ i β = β 1 xi 1 + · · · + βpxip Column Perspective:
Xβ = β 1 x(1)^ + · · · + βpx(p)
x(1),... , x(p)
where x(j)^ =
x 1 j x 2 j .. . xnj
, j = 1,... , p
Find among all the possible combinations of the columns of the design matrix the one that is closest to the target. L(X) = span
x(1),... , x(p)
=⇒ linear space created by matrix X.If y ∈ L(X), you would be able to express y as a linear combination of the regressors with no errors. In this case, y ∈/ L(X): find among all vectors in L(X), the one closest to y in terms of Euclidean distance.
Πy ⊥ L(X) ∈ L(X) Πy ⊥ L(X) = ˆy = βˆ 1 x(1)^ + · · · + βˆpx(p)^ = X βˆ
β^ ˆ is the vector of coefficients of Πy ⊥ L(X).
y = X βˆ + ˆϵ
y = ˆy + ˆϵ where yˆ is the fitted values and ˆϵ is the residuals. Assumptions:
dim(L(X)) = p dim(L⊥(X)) = n − p (less degrees of freedom)
This means that in the context of estimating parameters in a statistical model, each additional variable or parameter being estimated reduces the available degrees of freedom. For example, in simple linear regression with one predictor variable, there are n-2 degrees of freedom, where n is the number of ob- servations and 2 represents the intercept and slope being estimated. Adding more predictor variables further reduces the degrees of freedom available for estimating each parameter. Calculation The formula β = (X′X)−^1 X′y represents the calculation of coefficients in a linear regression model. Let’s break down the elements of this formula:
Now, let’s explain the steps involved in this formula:
MLE for β, σ^2 :
( βˆM LE , σˆ^2 ) = arg max β,σ^2
L(β, σ^2 |y)
Usually, maximize log L (log L = log likelihood):
( βˆM LE , σˆ^2 ) = arg max β,σ^2
L(β, σ^2 |y)
Proposition: Since X is full rank
β^ ˆM LE = (X′X)−^1 X′y ⇒ E[ βˆM LE ] = β (= βˆOLS )
ˆσ^2 M LE =
n
i
ˆε^2 i ⇒ E[ˆσ^2 M LE ] = n − p n
σ^2
ˆσ^2 M LE ’s bias is relevant for small n → use σˆ^2 RM LE
RMLE stand for restricted maximum likelihood and is use to obtain unbiased estimate of σ^2 Notice: y ∼ Nn(Xβ, σ^2 I)
βˆ = (X′X)−^1 X′y ∼ Np^ (β, σ^2 (X′X)−^1 )^ if collinearity, determinant = 0 → do not trust ε ˆ = ( I − H )y ∼ Nn(0, σ^2 ( I − H ))
Recall Linear transformation If W ∼ Nn(μ, Σ) and A q × n matrix what is the distribution of AW? AW ∼ Nq(Aμ, AΣA′)
Find ˆσ^2 RM LE = arg maxσ 2 L(σ^2 |εˆ) = (^) n^1 −p
∑n i=1 εˆ 2 i ⇒^ unbiased estimator of^ σ 2 Inference: With RMLE we can also estimate Var( βˆ) = Cov( βˆ) Notice Var( βˆ) = σ^2 (X′X)−^1 where σ^2 depends on estimation model used (OLS, RMLE, etc. → where σˆ OLS^2 = ˆσ^2 RM LE ) Estimate βˆRMLE of β = βˆMLE true for LM (independent observations with homogeneous variance). β^ ˆOLS and σˆ OLS^2 = βˆRMLE and ˆσ^2 RMLE true for LM (independent, homoscedastic residuals).
Var( βˆ) = σ^2 (X′X)−^1 estimated by Varˆ ( βˆ) = ˆσ^2 (X′X)−^1 where σ^2 = ˆσ^2 OLS = σˆ MLE^2 = σˆ^2 RMLE. Notice: Var-Cov matrices:
Before making any inference, check model assumptions. For a homogeneous linear model the key assumptions are:
The are different tools to check this assumptions.
Residual Diagnostics:
Raw Residuals: ε ˆi = yi − μˆi, where μˆi = x′ i βˆ (fitted value) Scaled Residuals: Raw εˆi divided by their estimated ˆσ (true σ rarely known).
But residual scaling does not address the variances of residuals εˆi differ even if variances of true errors εi are equal. This is connected to the Hat Matrix :
n × n matrix H: projection that maps vector y on the subspace spanned by columns of X. Vector of predicted values: y ˆ = Hy, εˆ = y − ˆy = (In − H)y
where In is the n × n identity matrix.If H is not proportional to In, raw residuals are potentially het- eroscedastic and/or correlated.
Var(ˆε) = σ^2 (In − H) (issue of heteroscedasticity)
Scaling addresses the issue of heteroscedasticity but introduces the issue of correlation between scaled residuals , which is addressed with Error Recovery Methods.
Methods to remove both heteroscedasticity and correlation of raw residuals εˆi, by transforming resid- uals so that they have μ = 0, constant variance, and are uncorrelated. n × n matrix P = In − H is not of full rank: if n > p, then rank of P ≤ n − p. Thus, we may have at most n − p transformed, uncorrelated residuals. Residuals of error recovery may represent more than one observation. → Difficult!
Testing: H 0 : Lβ = C 0 where L is a q × p matrix known. H 1 : Lβ ̸= C 0 C 0 = [ 0 · · · 0 ] Examples: Ex. 1)
(1 in position k)
Lβ = βk ⇒ H 0 : βk = 0 H 1 : βk ̸= 0
Ex. 2)
Lβ =
β 1 β 2
⇒ H 0 : β 1 = 0 and β 2 = 0
H 1 : β 1 ̸= 0 or β 2 ̸= 0
Ex. 3)
Lβ =
β 1 3 β 3 + β 4
⇒ H 0 : β 1 = 1 and 3 β 3 + β 4 = 25
H 1 : β 1 ̸= 1 or 3 β 3 + β 4 ̸= 25
WithC 0 =
Null Hypothesis (H 0 ): L βˆ = C 0 Alternative Hypothesis (H 1 ): L βˆ ̸= C 0
(L βˆ − C 0 )⊤(LVar( βˆ)L⊤)−^1 (L βˆ − C 0 ) q
Where q is the number of combinations.
If H 0 is true, F ∼ F(q,n−p)
Reject H 0 if F > Fα,q,n−p
L βˆ estimated by L βˆ : L βˆ ∼ N (Lβ, σ^2 L(X⊤X)−^1 L⊤) Remember: Var( βˆ) = σ^2 (X⊤X)−^1
Figure 1.4: F-distribution with 10 numerator and 10 denominator degrees of freedom.
L q × p matrix Inference: LP
F : ( βˆ′L′Var( βˆ)−^1 L βˆ) ∼ F (q, n − p) Degrees of Freedom (DoF) of LP: q (the number of rows of L matrix). For testing: H 0 : Lβ = C 0 (known matrix or vector) vs. H 1 : Lβ ̸= C 0 Example: H 0 : βi = 0 vs. H 1 : βi ̸= 0, i ∈ { 1... p}
L =
only 1 row, q = 1 (all 0 except 1 in position i).
( βˆi − C 0 )^2 Var( βˆi)
if H 0 : βi = C 0 , F = ( βˆi−C 0 )^2 Var( βˆi) Reject if: ( βˆi − C 0 )^2 Var( βˆi)
F 1 −α(q, n − p), α ∈ (0, 1)
⇒ equivalent to: | βˆi − C 0 | √ Var( βˆi)
t 1 − α 2 ,(n−p)
Remember: βˆi − C 0 √ Var( βˆi)
∼ t(n − p)
Reject H 0 if: | βˆi − C 0 | > t 1 − α 2 ,(n−p)
Var( βˆi)
Thus:
β^ ˆi ± t 1 − α 2 ,(n−p)
Var( βˆi) = C 1 −α/2( βˆi)
Note: The distribution is independent from the parameter you want to build your model on.
The BIC also taking into account the number of observations penalizes more The models with many observations, which however at the same time are The models where you tend to have higher accuracy. So if I take two models with the same variables and but the second one with twice as many observations as the other one will have very close AICs with the second one having a lower AIC tends to be,but I had computational waste to account for the additional observations. So maybe I gain 1% in accuracy to lose 100% in computational efficiency which the BIC takes into account in part.
BIC( β,ˆ ˆσ^2 ) = (log n) · p − 2 ℓ( β,ˆ σˆ^2 )
Penalize (log n) · p − 2 ℓ(β, σ^2 ). If n is large enough, logn > 2 (as in AIC) then the penalty term of the BIC (logn ∗ p > 2 p) will be higher than the penalty term of AIC (2p). Quantitative methods BUT remember some variables are relevant.
Sequential Approach: Add complexity to the model, starting from a simple model with just the intercept and possibly to stop early (interim results). Tests: Test H 0 H 1 x 4 1 1 + x 4 x 2 1 + x 4 1 + x 4 + x 2 x 3 1 + x 4 + x 2 1 + x 4 + x 2 + x 3 Marginal Approach (e.g., F-test): Data are collected before the testing and tests are applied to all data. Tests: Test H 0 H 1 x 4 1 + x 2 + x 3 1 + x 4 + x 2 + x 3 x 2 1 + x 4 + x 3 1 + x 4 + x 2 + x 3 x 3 1 + x 4 + x 2 1 + x 4 + x 2 + x 3
Now we relax the homoscedasticity assumption and allow for the observations to be heteroscedastic, i.e., to have different variances, while retaining the assumption that the observations are independent and normally distributed.We refer to this new class of models as LMs with heterogeneous variance.
Starting from the classical LM with homogeneous variance the variance Var(yi) of observation yi of the dependent variable is equal to σ^2. We now relax the constant variance assumption and assume that
Var(yi) = σ i^2. (1.11)
Therefore, we formulate an LM with heterogeneous variance (each observation can have different variance) by assuming that
yi = x(1) i β 1 + · · · + x( i p)βp + ϵi = x′ iβ + ϵi (1.12)
and
ϵi ∼ N (0, σ i^2 ), (1.13)
where ϵi are independent, i.e., ϵi is independent of ϵi′ for i ̸= i′. The fixed part of the LM is exactly the same as that of the classical LM with homogeneous variance. Similarly to the model with heterogeneous variance implies that
E(yi) ≡ μi = x′ iβ. (1.14)
It is important to note that the model contains in total n + p parameters, including n parameters σi and p parameters β. This is more than n, the number of observations. Therefore, the model is not identifiable. It may become identifiable, however, if we impose additional constraints on the residual variances σ^21 ,... , σ n^2. One simple way to impose such constraints is to assume known variance weights. We can now rewrite the model equations with a more compact form that will count also the new vari- ance structure. Toward this end, we define a diagonal matrix R :
R ≡ ΛΛ, (1.15)
where Λ = diag(λ 1 ,... , λn) is a diagonal matrix. We can specify the model as follows:
y = X β + ϵ, (1.16)
where ϵ ∼ N (0, R), R = σ^2 R , (1.17)
The simplest way to introduce heteroscedasticity and, at the same time, to reduce the number of vari- ance parameters in model is to assume that the variance of ϵi is equal to a known proportion of one (unknown) parameter σ^2. More specifically, we may associate with every observation i a known con- stant wi > 0 and assume that Var(ϵi) = Var(yi) = σ^2 /wi.
ϵi ∼ N (0, σ^2 /wi). (1.18)
Constants wi are called true weights. The higher the weight for a given observation, the lower the variance, i.e., the more precisely recorded the value of yi.
A more general and flexible way to introduce variance heterogeneity is by means of a variance func- tion.
λ(δ, μ, v ), (1.19)
which assumes positive values and is continuous and differentiable with respect to δ for all legitimate values of δ. Note that μ is a scalar and δ and v can be vectors. We can then assume that the variance of the residual errors, i.e., Var(ϵi), is expressed as follows:
Var(ϵi) = σ^2 λ^2 (δ, μi; v i), (1.20)
where: