An experiment compares the effect of two treatments on leaf length in plants.
12 observations for each treatment
Is it "Which treatment is best in this experiment?"
Is it "Which treatment is best in this experiment?"
The real aim is:
Can I say something more general about the difference between the treatments? Beyond this experiment.
Would I find the same or a similar effect again when I redo the experiment?
normal distribution -> for small samples: t-distribution
t-distributions for residuals Trt1
need to belong to the same, normal distribution with mean = 0
need to be independent from each other
Consequence: Simple linear models will not provide correct answers.
Possible solution...
too optimistic: all independent (too many degrees of freedom)
too strict: ignore individual observations at lowest level (too few degrees of freedom)
What we really need: a model that can find a right balance
experiments with study objects in blocks, or done on different days, assessed with different equipment, treated by different people,...
several observations on the same subject (same time, different time)
physical position of a study objects in an heterogeneous environment
genetic relationship among study objects
...
experiments with study objects in blocks, or done on different days, assessed with different equipment, treated by different people,...
several observations on the same subject (same time, different time)
physical position of a study objects in an heterogeneous environment
genetic relationship among study objects
...
Later on these dependencies will be described via groups or classes, whereas for others, a continuous distance could be used to indicate the relatedness.
Consequences for design/execution of an experiment
Be aware of the hierarchy
Pots perhaps more important than individual plants or leaves
Consequences for design/execution of an experiment
Be aware of the hierarchy
Pots perhaps more important than individual plants or leaves
Role of a factor in an experiment (...)
Consequences for interpretation
If you don't include variability of pots: conclusion limited to these pots
If you include variability of pots: conclusion extended to a similar set of pots
Dependence, is it a curse or a blessing?
Dependence, is it a curse or a blessing?
The reality is not independent (even the one we mimic/create in experiments)
Related observations can help/stabilize/improve a prediction of cases with imprecise observations
BUT: you have to realize there is dependence and find a proper solution for it (not (always) easy)
Models that use/model explicitly the
[blocks vs position in experiment]
Not normal distribution
many low values but impossible to go below zero
approximations via normal distribution and t-distributions to judge the difference and spread will not work anymore
Basic Linear model: fixed effects + simple residuals
Linear mixed model :
so: mixed models are models that include both fixed and random effects
Basic Linear model: fixed effects + simple residuals
Linear mixed model :
so: mixed models are models that include both fixed and random effects
LMM apply a more complex representation of the residuals that is capable to deal with the dependence structure.
hence alternative name for random effect: Variance Component
A simple situation with 2 treatments A and B, with 4 observations each
y1=bA+e1y2=bA+e2y3=bA+e3⋮y7=bB+e7y8=bB+e8y1=bA+e1y2=bA+e2y3=bA+e3⋮y7=bB+e7y8=bB+e8
Y=Xβ+εY=Xβ+ε
with ε=e1,e2,..,e8ε=e1,e2,..,e8
A simple situation with 2 treatments A and B, with 4 observations each
y1=bA+e1y2=bA+e2y3=bA+e3⋮y7=bB+e7y8=bB+e8y1=bA+e1y2=bA+e2y3=bA+e3⋮y7=bB+e7y8=bB+e8
Y=Xβ+εY=Xβ+ε
with ε=e1,e2,..,e8ε=e1,e2,..,e8
every eiei is a drawn from a normal distribution, all with mean = zero. N(0,σ1),N(0,σ2),...,N(0,σ8)N(0,σ1),N(0,σ2),...,N(0,σ8)
In linear models we assume 'residuals are identically and independently distributed'.
Identically:
σ1=σ2=σ3=...=σσ1=σ2=σ3=...=σ
so N(0,σ1),N(0,σ2),...,N(0,σ8)N(0,σ1),N(0,σ2),...,N(0,σ8) becomes N(0,σ),N(0,σ),...,N(0,σ)N(0,σ),N(0,σ),...,N(0,σ)
independently means the draw of e2e2 does not depend on e1 and vice versa.
hence:
(e1,e2)∼N(0,Σ) with
Σ=[σ2covcovσ2]=[σ200σ2]
as cov = 0
Σa=[1001] Σb=[1002] Σc=[10.60.61]
Suppose all 8 observations are independent
ε is distributed N(0,Σ) (=normal distribution with a mean 0 and variance-covariance matrix Σ)
with:
Σ=[σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ2]
Σ only contains one σ and that only on the diagonal (covariance = 0)
i.e the simple linear model.
Σ=[σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ2]
The simple linear caseΣ=[σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ2]
The simple linear caseΣ=[σ21σ2aσ2bσ2c....σ2aσ22σ2kσ2l....σ2bσ2kσ23σ2k....σ2cσ2lσ2kσ24........σ25........σ26........σ28........σ29]
The ultimate but impossible caseΣ=[σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ2]
Y=Xβ+ε
Σ=[σ2100000000σ2100000000σ2100000000σ2100000000σ2200000000σ2200000000σ2200000000σ22]
Y=Xβ+ε with a different variance for A and B (heteroscedastic model)
Σ=[σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ2]
Y=Xβ+ε
Σ=[σ2σ21000000σ21σ200000000σ2σ21000000σ21σ200000000σ2σ21000000σ21σ200000000σ2σ21000000σ21σ2]
split up Σ in a part that deals with the yellow and part that deals with the red part ("the random effect")
Y=Xβ+Zu+ε
Other possibility is to apply a function that results in decreasing covariance over "distance":
Σ=[σ2σ21σ21/200000σ21σ2σ21σ21/20000σ21/2σ21σ2σ21σ21/20000σ21/2σ21σ2σ21σ21/20000σ21/2σ21σ2σ21σ21/20000σ21/2σ21σ2σ21σ21/20000σ21/2σ21σ2σ2100000σ21/2σ21σ2]
Σ=σ2s[1dadbdc....da1dgdh....dbdg1dk....dcdhdk1........1........1........1........1]
Specific but very common case of dependency
Many different ways to handle, depending on the objective and setup of the experiment or study, and prior knowledge
Yet another case of dependency
As with longitudinal observations, but now multiple parameters measured on same objects
Relying on correlation between the multiple parameters to improve the estimation of the main one
no more ordinary least squares, but algorithms that have to converge to stable solutions
Frequentist:
Bayesian:
Hence: output will always differ a little
Let's dive in it: https://hw-appliedlinmixmodinr.netlify.app//
We will not cover everything in detail. It is a reference.
https://hw-appliedlinmixmodinr.netlify.app//
Not normal distribution
many low values but impossible to go below zero
approximations via normal distribution and t-distributions to judge the difference and spread will not work anymore
The generalization part deals with two issues:
the response can impossibly change proportionally with the predictor(s)
the response is not normally distributed
while remaining within the realm of linear models
Usually:
count data: poisson or negative binomial distribution with log link
yes/no - 0/1 data: binomial distribution with logit link
skewed continuous data strictly positive: gamma distribution with log link
observed continuous proportions: beta distribution with logit link
data with too many zeros: zero-inflated versions of the above
other (censored, zero-inflated, ratios of 2 observed,...): seek help
https://hw-appliedgeneralizedlinmixmodinr.netlify.app/
Content of the document:
practical examples with lme4, brms and inla
lme4::glmer()brms::brm()INLA::inla()how to interpret the output
We will not cover everything in detail. It is a reference.
An experiment compares the effect of two treatments on leaf length in plants.
12 observations for each treatment
Keyboard shortcuts
| ↑, ←, Pg Up, k | Go to previous slide |
| ↓, →, Pg Dn, Space, j | Go to next slide |
| Home | Go to first slide |
| End | Go to last slide |
| Number + Return | Go to specific slide |
| b / m / f | Toggle blackout / mirrored / fullscreen mode |
| c | Clone slideshow |
| p | Toggle presenter mode |
| t | Restart the presentation timer |
| ?, h | Toggle this help |
| s | Toggle scribble toolbox |
| o | Tile View: Overview of Slides |
| Esc | Back to slideshow |
An experiment compares the effect of two treatments on leaf length in plants.
12 observations for each treatment
Is it "Which treatment is best in this experiment?"
Is it "Which treatment is best in this experiment?"
The real aim is:
Can I say something more general about the difference between the treatments? Beyond this experiment.
Would I find the same or a similar effect again when I redo the experiment?
normal distribution -> for small samples: t-distribution
t-distributions for residuals Trt1
need to belong to the same, normal distribution with mean = 0
need to be independent from each other
Consequence: Simple linear models will not provide correct answers.
Possible solution...
too optimistic: all independent (too many degrees of freedom)
too strict: ignore individual observations at lowest level (too few degrees of freedom)
What we really need: a model that can find a right balance
experiments with study objects in blocks, or done on different days, assessed with different equipment, treated by different people,...
several observations on the same subject (same time, different time)
physical position of a study objects in an heterogeneous environment
genetic relationship among study objects
...
experiments with study objects in blocks, or done on different days, assessed with different equipment, treated by different people,...
several observations on the same subject (same time, different time)
physical position of a study objects in an heterogeneous environment
genetic relationship among study objects
...
Later on these dependencies will be described via groups or classes, whereas for others, a continuous distance could be used to indicate the relatedness.
Consequences for design/execution of an experiment
Be aware of the hierarchy
Pots perhaps more important than individual plants or leaves
Consequences for design/execution of an experiment
Be aware of the hierarchy
Pots perhaps more important than individual plants or leaves
Role of a factor in an experiment (...)
Consequences for interpretation
If you don't include variability of pots: conclusion limited to these pots
If you include variability of pots: conclusion extended to a similar set of pots
Dependence, is it a curse or a blessing?
Dependence, is it a curse or a blessing?
The reality is not independent (even the one we mimic/create in experiments)
Related observations can help/stabilize/improve a prediction of cases with imprecise observations
BUT: you have to realize there is dependence and find a proper solution for it (not (always) easy)
Models that use/model explicitly the
[blocks vs position in experiment]
Not normal distribution
many low values but impossible to go below zero
approximations via normal distribution and t-distributions to judge the difference and spread will not work anymore
Basic Linear model: fixed effects + simple residuals
Linear mixed model :
so: mixed models are models that include both fixed and random effects
Basic Linear model: fixed effects + simple residuals
Linear mixed model :
so: mixed models are models that include both fixed and random effects
LMM apply a more complex representation of the residuals that is capable to deal with the dependence structure.
hence alternative name for random effect: Variance Component
A simple situation with 2 treatments A and B, with 4 observations each
y1=bA+e1y2=bA+e2y3=bA+e3⋮y7=bB+e7y8=bB+e8
Y=Xβ+ε
with ε=e1,e2,..,e8
A simple situation with 2 treatments A and B, with 4 observations each
y1=bA+e1y2=bA+e2y3=bA+e3⋮y7=bB+e7y8=bB+e8
Y=Xβ+ε
with ε=e1,e2,..,e8
every ei is a drawn from a normal distribution, all with mean = zero. N(0,σ1),N(0,σ2),...,N(0,σ8)
In linear models we assume 'residuals are identically and independently distributed'.
Identically:
σ1=σ2=σ3=...=σ
so N(0,σ1),N(0,σ2),...,N(0,σ8) becomes N(0,σ),N(0,σ),...,N(0,σ)
independently means the draw of e2 does not depend on e1 and vice versa.
hence:
(e1,e2)∼N(0,Σ) with
Σ=[σ2covcovσ2]=[σ200σ2]
as cov = 0
Σa=[1001] Σb=[1002] Σc=[10.60.61]
Suppose all 8 observations are independent
ε is distributed N(0,Σ) (=normal distribution with a mean 0 and variance-covariance matrix Σ)
with:
Σ=[σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ2]
Σ only contains one σ and that only on the diagonal (covariance = 0)
i.e the simple linear model.
Σ=[σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ2]
The simple linear caseΣ=[σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ2]
The simple linear caseΣ=[σ21σ2aσ2bσ2c....σ2aσ22σ2kσ2l....σ2bσ2kσ23σ2k....σ2cσ2lσ2kσ24........σ25........σ26........σ28........σ29]
The ultimate but impossible caseΣ=[σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ2]
Y=Xβ+ε
Σ=[σ2100000000σ2100000000σ2100000000σ2100000000σ2200000000σ2200000000σ2200000000σ22]
Y=Xβ+ε with a different variance for A and B (heteroscedastic model)
Σ=[σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ200000000σ2]
Y=Xβ+ε
Σ=[σ2σ21000000σ21σ200000000σ2σ21000000σ21σ200000000σ2σ21000000σ21σ200000000σ2σ21000000σ21σ2]
split up Σ in a part that deals with the yellow and part that deals with the red part ("the random effect")
Y=Xβ+Zu+ε
Other possibility is to apply a function that results in decreasing covariance over "distance":
Σ=[σ2σ21σ21/200000σ21σ2σ21σ21/20000σ21/2σ21σ2σ21σ21/20000σ21/2σ21σ2σ21σ21/20000σ21/2σ21σ2σ21σ21/20000σ21/2σ21σ2σ21σ21/20000σ21/2σ21σ2σ2100000σ21/2σ21σ2]
Σ=σ2s[1dadbdc....da1dgdh....dbdg1dk....dcdhdk1........1........1........1........1]
Specific but very common case of dependency
Many different ways to handle, depending on the objective and setup of the experiment or study, and prior knowledge
Yet another case of dependency
As with longitudinal observations, but now multiple parameters measured on same objects
Relying on correlation between the multiple parameters to improve the estimation of the main one
no more ordinary least squares, but algorithms that have to converge to stable solutions
Frequentist:
Bayesian:
Hence: output will always differ a little
Let's dive in it: https://hw-appliedlinmixmodinr.netlify.app//
We will not cover everything in detail. It is a reference.
https://hw-appliedlinmixmodinr.netlify.app//
Not normal distribution
many low values but impossible to go below zero
approximations via normal distribution and t-distributions to judge the difference and spread will not work anymore
The generalization part deals with two issues:
the response can impossibly change proportionally with the predictor(s)
the response is not normally distributed
while remaining within the realm of linear models
Usually:
count data: poisson or negative binomial distribution with log link
yes/no - 0/1 data: binomial distribution with logit link
skewed continuous data strictly positive: gamma distribution with log link
observed continuous proportions: beta distribution with logit link
data with too many zeros: zero-inflated versions of the above
other (censored, zero-inflated, ratios of 2 observed,...): seek help
https://hw-appliedgeneralizedlinmixmodinr.netlify.app/
Content of the document:
practical examples with lme4, brms and inla
lme4::glmer()brms::brm()INLA::inla()how to interpret the output
We will not cover everything in detail. It is a reference.