glm()

advertisement
Today:
Lab 9ab due
after lecture: CEQ
DEC 8 – 9am
FINAL EXAM
EN 2007
Monday:
Quizz 11: review
Wednesday:
Guest lecture – Multivariate Analysis
Friday:
last lecture: review – Bring questions
Biology 4605 / 7220
Quiz #10a
Name ________________
19 November 2012
1. What are the 2 main differences between general linear
models and generalized linear models?
2. A generalized linear model links a response variable to one or
more explanatory variables Xi according to a link function.
Biology 4605 / 7220
Quiz #10a
Name ________________
19 November 2012
1. What are the 2 main differences between general linear
models and generalized linear models?
Most common answers:
implementation
A. Non –normal ε
B. ANODEV instead of ANOVA table
conceptual
C. Link function
2. A generalized linear model links a response variable to one or
more explanatory variables Xi according to a link function.
GLM, GzLM, GAM
A few concepts and ideas
GLM
Model based statistics – we define the response and the
explanatory without worrying about the name of the test
GLM
GENERAL LINEAR MODELS
ε ~ Normal
ANOVA
R: lm()
Multiple Linear Regression
t-test
Simple Linear Regression
ANCOVA
GLM
An example from Lab 9
GLM
Do fumigants (treatments) decrease the number of wire worms?
#ww = β0 + βtreatment treatment + βrow row + βcolumn column
treatment  fixed
row
 random
column
 random
N=25
2
0
-2
-4
worm.lm$residuals
4
GLM
0
2
4
6
8
worm.lm$fitted.values
10
12
N=25
GLM
Normal Q-Q
1
0
-1
-2
Standardized residuals
2
4
24
-2
3
-1
0
Theoretical Quantiles
lm(nw ~ trt + row + col)
1
2
N=25
4
2
0
Frequency
6
8
GLM
-4
-2
0
worm.lm$residuals
2
4
N=25
2
0
-2
-4
worm.lm$residuals[2:25]
4
GLM
-4
-2
0
2
worm.lm$residuals[1:24]
4
N=25
GLM
p-value borderline
Normality assumption not met
GLM
p-value borderline
Normality assumption not met
n<30
Given that we do not violate the homogeneity assumption,
randomizing will likely not change our decision… or will it?
Let’s try  prand = 0.0626
(50 000 randomizations)
N=25
Parameters:
Means with 95% CI
Number of wire worms
10
GLM
-2
Anything wrong with this analysis?
0
1
2
Treatment
3
4
GLM
Response variable?
Counts
GzLM
Poisson error
#ww = eμ + ε
μ = β0 + βtreatment treatment + βrow row + βcolumn column
GzLM
Poisson error
#ww = eμ + ε
μ = β0 + βtreatment treatment + βrow row + βcolumn column
ALL fits > 0
GzLM
Poisson error
-2
-2
Number of wire worms
10
Poisson error
10
Normal error
0
1
2
Treatment
3
4
0
1
2
Treatment
3
4
GzLM
Poisson error
-2
-2
Number of wire worms
10
Poisson error
10
Normal error
0
1
2
Treatment
3
4
0
1
2
Treatment
3
4
GzLM
GENERALIZED LINEAR MODELS
Linear combination of parameters
R: glm()
Binomial
Poisson
Multinomial
GENERAL LINEAR MODELS
ε ~ Normal
ANOVA
R: lm()
Multiple Linear Regression
t-test
Simple Linear Regression
ANCOVA
Exponential
Negative Binomial
Inverse Gaussian
Gamma
GzLM
#ww = eμ + ε
μ = β0 + βtreatment treatment + βrow row + βcolumn column
Generalized linear models have 3 components:
Systematic
Random
Link function
GzLM
#ww = eμ + ε
μ = β0 + βtreatment treatment + βrow row + βcolumn column
Generalized linear models have 3 components:
Systematic
linear predictor
Random
Link function
GzLM
#ww = eμ + ε
μ = β0 + βtreatment treatment + βrow row + βcolumn column
Generalized linear models have 3 components:
Systematic
linear predictor
Random
probability distribution  poisson error
Link function
GzLM
#ww = eμ + ε
μ = β0 + βtreatment treatment + βrow row + βcolumn column
Generalized linear models have 3 components:
Systematic
linear predictor
Random
probability distribution  poisson error
Link function
log
GzLM
GLM
20
10
0
distance
30
40
An example from Lab 6
2
4
6
period
8
10
12
GLM
Do movements of juvenile cod depend on time of day?
distance = β0 + βperiod period
period  categorical
GLM
20
distance
30
40
GLM
0
10
Anything wrong with this analysis?
2
4
6
period
8
10
12
0
10
20
Distance
30
40
GAM
2
4
6
Time
8
10
12
GENERALIZED ADDITIVE MODELS
GAM
R: gam()
GENERALIZED LINEAR MODELS
Linear combination of parameters
R: glm()
Binomial
Poisson
Multinomial
GENERAL LINEAR MODELS
ε ~ Normal
ANOVA
R: lm()
Multiple Linear Regression
t-test
Simple Linear Regression
ANCOVA
Exponential
Negative Binomial
Inverse Gaussian
Gamma
Non-linear
effect of
covariates
GAM
Generalized case of generalized linear models where the systematic
component is not necessarily linear
distance ~ s(period)
y ~ s(x1) + s(x2) + x3 + ….
s: smooth function
Spline functions are concerned with good approximation of
functions over the whole of a region, and behave in a stable manner
GAM
Smoothing - concept
GAM
How much smoothing?
-
Degree of smoothness
+
GAM
GENERAL LINEAR MODELS
ε ~ Normal
ANOVA
R: lm()
Multiple Linear Regression
t-test
Simple Linear Regression
ANCOVA
GENERALIZED LINEAR MODELS
Linear combination of parameters
R: glm()
Binomial
Poisson
Multinomial
GENERAL LINEAR MODELS
ε ~ Normal
ANOVA
R: lm()
Multiple Linear Regression
t-test
Simple Linear Regression
ANCOVA
Exponential
Negative Binomial
Inverse Gaussian
Gamma
Non-normal ε
Link function
GENERALIZED ADDITIVE MODELS
R: gam()
GENERALIZED LINEAR MODELS
Linear combination of parameters
R: glm()
Binomial
Poisson
Multinomial
GENERAL LINEAR MODELS
ε ~ Normal
ANOVA
R: lm()
Multiple Linear Regression
t-test
Simple Linear Regression
ANCOVA
Exponential
Negative Binomial
Inverse Gaussian
Gamma
Linear predictor
involves sums of
smooth
functions of
covariates
Non-linear
effect of
covariates
Download