Professional Documents
Culture Documents
GLM 2
GLM 2
> x1<-c(0,0,0,1,0,0,1,1,2,0,1,0,1,0,0,2,1,3,1,0,0,1,1,0,0,1)
> x2<-c(1,2,1,1,2,2,2,2,2,2,2,3,2,2,2,2,3,2,2,2,2,2,2,2,2,2)
>
x3<-c(35,49,50,55,48,52,53,59,66,57,54,57,54,54,54,49,51,58,60,51,63,50,53,53,55,56)
> help("mean")
> mean(x1)
[1] 0.6538462
> var(x1)
[1] 0.6353846
> ex2<-glm(x1 ~ x2 + x3, family=poisson)
> ex2
Call:
Coefficients:
(Intercept)
-4.504912
x2
0.003265
x3
0.074355
3Q
0.4472
Max
1.8350
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -4.504912
2.755749 -1.635
0.102
x2
0.003265
0.634167
0.005
0.996
x3
0.074355
0.046938
1.584
0.113
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 26.583
Residual deviance: 23.956
AIC: 58.175
on 25
on 23
degrees of freedom
degrees of freedom
3Q
0.4473
Max
1.8349
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -4.50029
2.60467 -1.728
0.084 .
x3
0.07439
0.04646
1.601
0.109
Page 1
glm2
--Signif. codes:
on 25
on 24
degrees of freedom
degrees of freedom
= poisson)
Call:
glm(formula = x1 ~ x3 + x4, family = poisson)
Deviance Residuals:
Min
1Q
Median
-1.5317 -1.0698 -0.2023
3Q
0.4759
Max
1.8043
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -8.141169 18.335651 -0.444
0.657
x3
0.205471
0.651799
0.315
0.753
x4
-0.001170
0.005779 -0.202
0.840
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 26.583
Residual deviance: 23.911
AIC: 58.13
on 25
on 23
degrees of freedom
degrees of freedom
> x5<-x2*x3
> x6<-x2*x2
> ex2d<-glm(x1 ~ x3 + x4 + x5 +x6, family
> summary(ex2d)
= poisson)
Call:
glm(formula = x1 ~ x3 + x4 + x5 + x6, family = poisson)
Deviance Residuals:
Min
1Q
Median
-1.5328 -1.0660 -0.2020
3Q
0.4749
Max
1.8061
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -8.475169 18.505488 -0.458
0.647
x3
0.219621
0.660502
0.333
0.740
x4
-0.001212
0.005914 -0.205
0.838
x5
-0.004214
0.055139 -0.076
0.939
x6
0.035665
0.726436
0.049
0.961
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 26.583
on 25
degrees of freedom
Page 2
glm2
degrees of freedom
on 21
family
= poisson)
Call:
glm(formula = x1 ~ x3 + x4 + x5, family = poisson)
Deviance Residuals:
Min
1Q
Median
-1.5338 -1.0695 -0.2044
3Q
0.4757
Max
1.8000
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -8.469234 18.487201 -0.458
0.647
x3
0.219740
0.660009
0.333
0.739
x4
-0.001263
0.005816 -0.217
0.828
x5
-0.001570
0.011983 -0.131
0.896
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 26.583
Residual deviance: 23.894
AIC: 60.113
on 25
on 22
degrees of freedom
degrees of freedom
Page 3