Download presentation
Presentation is loading. Please wait.
1
Linear models OUTLINE: Predictions
Contrasts (difference between predictions) Confidence intervals of predictions and contrast Matrix notation Exercises – Theory – Back to exercises
2
What are linear models? All linear models can be written on the form
Growth rate Temperature All linear models can be written on the form Growth rate Temperature Males Females Growth rate Temperature Males Females Males Growth rate Temperature Non-linear models often have linear components – transformation of ”super parameters” have linear constraints (e.g. occupancy models). Females
3
Y X Some basic notation (xi,yi) Obs. (i) X Y 1 x1 y1 2 x2 y2 3 x3 y3 4
5 x5 y5 X
4
Exercises! Matrix multiplication:
5
All linear models can be written as
Example – growth experiment of tomato plants: Response variable (Y): ’Height’ at the end of the experiment Predictor variable: ’Light’: 3 levels of light (low, medium, high) ’Soil’ type (A or B) All linear models can be written as Data: model.matrix( y ~ light + soil + light:soil ) Light Soil Height Low A y1 y2 B y3 y4 Med y5 y6 y7 y8 High y9 y10 y11 y12 intercept Light_med Light_high Soil_B Light_med & Soil_B 1
6
Medium light intensity
Soil Height Low A y1 y2 B y3 y4 Med y5 y6 y7 y8 High y9 y10 y11 y12 intercept Light_med Light_high Soil_B Light_med & Soil_B 1 model.matrix( y ~ light + soil + light:soil ) Soil B Soil A Height (Y) Low light intensity Medium light intensity High light intensity
7
Medium light intensity
Soil Height Low A y1 y2 B y3 y4 Med y5 y6 y7 y8 High y9 y10 y11 y12 intercept Light_med Light_high Soil_B Light_med & Soil_B 1 model.matrix( y ~ light + soil ) Soil B Soil A Height (Y) Low light intensity Medium light intensity High light intensity
8
Medium light intensity
Soil Height Low A y1 y2 B y3 y4 Med y5 y6 y7 y8 High y9 y10 y11 y12 intercept Light_med Light_high Soil_B Light_med & Soil_B 1 model.matrix( y ~ light + soil ) Soil B Soil A Height (Y) Low light intensity Medium light intensity High light intensity
9
How to we get standard errors of the predictions?
Light Soil Height Low A y1 y2 B y3 y4 Med y5 y6 y7 y8 High y9 y10 y11 y12 intercept Light_med Light_high Soil_B Light_med & Soil_B 1 X = model.matrix(y ~ light + soil + light:soil) beta = coef(lm(y ~ light + soil + light:soil)) Fitted predictions: Height (Y) Low light intensity Medium light intensity High light intensity How to we get standard errors of the predictions?
10
How to we get standard errors on the predictions?
Two parameters: Three parameters: Any number of parameters: Approximation for non-linear functions (delta method): Variance-covariance matrix of fitted predictions: Replace the vector x with: Variances of fitted predictions:
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.