Linear Model 1
Linear Model 1
Presidency University
November, 2023
General Linear model
I In the most general form, consider a setup where we have a single
response variable y which is quantitative and p covariates x1 , x2 , ...., xp
which can be either quantitative or qualitative or both.
General Linear model
I In the most general form, consider a setup where we have a single
response variable y which is quantitative and p covariates x1 , x2 , ...., xp
which can be either quantitative or qualitative or both.
y = Xβ +
where y = (y1 , y2 , ..., yn ) is the response vector and β = (b1 , ..., bp ) is the
vector of parameters and
E (y |X ) = X β and Var (y |X ) = σ 2 In .
Example of linear model: Snell’s law
I Snell’s law relates the angle of incidence (θ1 ) with the angle of
refraction (θ2 ), when light crosses the boundary between two
media, as
sin θ2 = κ sin θ1
where κ is the ratio of refractive indices of the two media.
Example of linear model: Snell’s law
I Snell’s law relates the angle of incidence (θ1 ) with the angle of
refraction (θ2 ), when light crosses the boundary between two
media, as
sin θ2 = κ sin θ1
where κ is the ratio of refractive indices of the two media.
y = βx +
y = Xθ +
I Since congestion affects speed (and not the other way around)
we are interested in determining the effect of density on speed.
Example (Contd.)
40
35
30
SPEED
25
20
15
10
DENSITY
Example (Contd.)
I The plot speed and density suggests a quadratic relationship.
Example (Contd.)
I The plot speed and density suggests a quadratic relationship.
I Hence we opt for a model of the form
y = α + βx + γx 2 +
y = α + βx + γx 2 +
y = Xθ +
y = α + β1 x1 + β2 x2 + ... + βk xk +
Using dummy for all levels
I Now suppose in the same situation we use k dummy variables x1 , x2 , ..., xk
instead of k − 1 variables x1 , x2 , ..., xk−1 and fit a model as
y = α + β1 x1 + β2 x2 + ... + βk xk +
I Then we note that the variables x1 , x2 , ..., xk are not independent : they satisfy
P
a constraint xi = 1, that is any observation must receive any one of the levels
Ai .
Using dummy for all levels
I Now suppose in the same situation we use k dummy variables x1 , x2 , ..., xk
instead of k − 1 variables x1 , x2 , ..., xk−1 and fit a model as
y = α + β1 x1 + β2 x2 + ... + βk xk +
I Then we note that the variables x1 , x2 , ..., xk are not independent : they satisfy
P
a constraint xi = 1, that is any observation must receive any one of the levels
Ai .
y = α + β1 x1 + β2 x2 + ... + βk xk +
I Then we note that the variables x1 , x2 , ..., xk are not independent : they satisfy
P
a constraint xi = 1, that is any observation must receive any one of the levels
Ai .
I Statistical lesson: There can be alternative parametrization for the same model.
Example: ANOVA model (One way layout)
I Suppose we have a factor A and let A1 , A2 , ...., Ak be the levels of A
which constitutes the population of interest.
Example: ANOVA model (One way layout)
I Suppose we have a factor A and let A1 , A2 , ...., Ak be the levels of A
which constitutes the population of interest.
I Further assume there are ni observations receiving the level Ai and yij be
the j th observation receiving the i th level Ai .
Example: ANOVA model (One way layout)
I Suppose we have a factor A and let A1 , A2 , ...., Ak be the levels of A
which constitutes the population of interest.
I Further assume there are ni observations receiving the level Ai and yij be
the j th observation receiving the i th level Ai .
where
µi = fixed effect due to Ai and eij = random error.
Example: ANOVA model (One way layout)
I Suppose we have a factor A and let A1 , A2 , ...., Ak be the levels of A
which constitutes the population of interest.
I Further assume there are ni observations receiving the level Ai and yij be
the j th observation receiving the i th level Ai .
where
µi = fixed effect due to Ai and eij = random error.
I We assume that
eij ∼ N(0, σ 2 )
and eij0 s are independent.
Example: ANOVA model (One way layout)
I Suppose we have a factor A and let A1 , A2 , ...., Ak be the levels of A
which constitutes the population of interest.
I Further assume there are ni observations receiving the level Ai and yij be
the j th observation receiving the i th level Ai .
where
µi = fixed effect due to Ai and eij = random error.
I We assume that
eij ∼ N(0, σ 2 )
and eij0 s are independent.
I This implies that E (yij ) = µi and Var (yij ) = σ 2 for all j = 1, ..., ni which
means µ0i s are the factor level means for each i and σ 2 is the common
variability among observations belonging to each group.
Interpretation of parameters
I In an experimental study, the factor level mean µi stands for the mean
response that would be obtained if the i th treatment were applied to all
unit in the population of experimental units about which inferences are to
be drawn. Similarly, the variance σ 2 refers to the variability of responses
if any given experimental treatment were applied to the entire population
of experimental units.
Interpretation (Contd.)
I In an experimental study, the factor level mean µi stands for the mean
response that would be obtained if the i th treatment were applied to all
unit in the population of experimental units about which inferences are to
be drawn. Similarly, the variance σ 2 refers to the variability of responses
if any given experimental treatment were applied to the entire population
of experimental units.
y = µ1 x1 + µ2 x2 + .... + µk xk +
y11 e11
y12 e12
.. ..
. .
y1n e1n
1 1
1n1 0 ··· 0
y21
µ1 e21
. µ2 0 1n2 ··· 0 .
y = .. , β = . and Xn×k = .
.
.. .. .. and = .
.. ..
y2n2
. . . e2n2
.
. µ k 0 0 ··· 1nk .
.
. .
yk1 ek1
. .
.. ..
yknk eknk
One way ANOVA as linear model
I Suppose we denote
y11 e11
y12 e12
.. ..
. .
y1n e1n
1 1
1n1 0 ··· 0
y21
µ1 e21
. µ2 0 1n2 ··· 0 .
y = .. , β = . and Xn×k = .
.
.. .. .. and = .
.. ..
y2n2
. . . e2n2
.
. µ k 0 0 ··· 1nk .
.
. .
yk1 ek1
. .
.. ..
yknk eknk
y = Xβ +
2
where ∼ Nn (0, σ In ).
Reparametrization
I At times, an alternative but completely equivalent formulation of the
single-factor ANOVA model is used. This alternative formulation is called
the factor effects model.
Reparametrization
I At times, an alternative but completely equivalent formulation of the
single-factor ANOVA model is used. This alternative formulation is called
the factor effects model.
I Let us write
µi = µ̄ + (µi − µ̄) = µ + αi
P
ni µi
where µ = µ̄ = n
and αi = µi − µ̄.
Reparametrization
I At times, an alternative but completely equivalent formulation of the
single-factor ANOVA model is used. This alternative formulation is called
the factor effects model.
I Let us write
µi = µ̄ + (µi − µ̄) = µ + αi
P
ni µi
where µ = µ̄ = n
and αi = µi − µ̄.
X
I Then we note that ni αi = 0.
i
Reparametrization
I At times, an alternative but completely equivalent formulation of the
single-factor ANOVA model is used. This alternative formulation is called
the factor effects model.
I Let us write
µi = µ̄ + (µi − µ̄) = µ + αi
P
ni µi
where µ = µ̄ = n
and αi = µi − µ̄.
X
I Then we note that ni αi = 0.
i
where µ denotes the general effect or the average effect and αi denotes
the
X additional effect (fixed) due to Ai subject to the restriction
ni αi = 0 and eij denotes the random error.
i
Reparametrization
I At times, an alternative but completely equivalent formulation of the
single-factor ANOVA model is used. This alternative formulation is called
the factor effects model.
I Let us write
µi = µ̄ + (µi − µ̄) = µ + αi
P
ni µi
where µ = µ̄ = n
and αi = µi − µ̄.
X
I Then we note that ni αi = 0.
i
where µ denotes the general effect or the average effect and αi denotes
the
X additional effect (fixed) due to Ai subject to the restriction
ni αi = 0 and eij denotes the random error.
i
y = Xβ +
I Note that we allow the number of observations in the two groups to be different
and y ’s represent the value of the response.
Example: More use of dummy variables
I Consider a setup where we need to judge the effectiveness of a treatment (or
may be comparing the effectiveness of two treatments, in which case the control
group may be thought of getting some treatment). This may be a controlled
experiment or observational study.
I Note that we allow the number of observations in the two groups to be different
and y ’s represent the value of the response.
I This situation can also be tackled with a linear model with the use of dummy
variables.
More use of dummy (contd.)
I Let us define a dummy variable as
z = α + βx +
or more precisely
z = α + βx +
or more precisely
I Here (
y1i , i = 1, 2, ..., n1
zi =
y2(i−n1 ) , i = n1 + 1, ..., n1 + n2
and 1 , 2 , ..., n are the random errors.
More use (Contd.)
I Suppose we write the above linear model as
z = X θ + .
More use (Contd.)
I Suppose we write the above linear model as
z = X θ + .
z = X θ + .
where the upper submatrix consists of n1 rows and the lower one contains
n2 rows.
More use (Contd.)
I Suppose we write the above linear model as
z = X θ + .
where the upper submatrix consists of n1 rows and the lower one contains
n2 rows.
I Note that in the above formulation the effect of the treatment is α + β and the
effect of the control is α- so the change in effect due to the treatment is β.