Description
Unformatted Attachment Preview
Purchase answer to see full attachment
Explanation & Answer
View attached explanation and answer. Let me know if you have any questions.
Answer
library(MASS)
data = read.csv("C:/Users/j boy/Dropbox/PC/Desktop/Glr_data.csv")
data
##
Observation Age Deaths Person_years_at_risk Smoker
## 1
1
1
32
52407
1
## 2
2
2
104
43248
1
## 3
3
3
206
28612
1
## 4
4
4
186
12663
1
## 5
5
5
102
5317
1
## 6
6
1
2
18790
2
## 7
7
2
12
10673
2
## 8
8
3
28
5710
2
## 9
9
4
28
2585
2
## 10
10
5
31
1462
2
Smoker_f = factor(data$Smoker, levels =c(1, 2))
is.factor(Smoker_f)
## [1] TRUE
levels(Smoker_f)
## [1] "1" "2"
#question a #
reg_output = glm(formula = Deaths ~ Age + I(Age^2) + Smoker + Age * Smoker +
log(Person_years_at_risk), family = poisson, data = data)
summary(reg_output)
##
## Call:
## glm(formula = Deaths ~ Age + I(Age^2) + Smoker + Age * Smoker +
##
log(Person_years_at_risk), family = poisson, data = data)
##
## Deviance Residuals:
##
1
2
3
4
5
6
7
8
## 0.32165 -0.30774
0.03825
0.09349 -0.04309 -0.68101
0.20454
6966
##
9
10
## -0.61900
0.16801
##
## Coefficients:
##
Estimate Std. Error z value Pr(>|z|)
## (Intercept)
-5.18769
6.38225 -0.813 0.416314
## Age
1.76679
0.20407
8.658 < 2e-16 ***
## I(Age^2)
-0.22104
0.06116 -3.614 0.000302 ***
## Smoker
-1.77851
0.87658 -2.029 0.042466 *
## log(Person_years_at_risk) 0.78366
0.50565
1.550 0.121193
0.5
## Age:Smoker
0.31294
0.09935
3.150 0.001633 **
## --## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
##
Null d...