Questão 5

# Criando os vetores com os dados
nascimentos <- c(236.00, 739.00, 970.00, 2371.00, 309.00, 679.00, 26.00, 1272.00, 
                 3246.00, 1904.00, 357.00, 1080.00, 1027.00, 28.00, 2507.00, 138.00, 
                 502.00, 1501.00, 2750.00, 192.00)

tipo_hospital <- c(0.00, 1.00, 1.00, 1.00, 1.00, 1.00, 0.00, 1.00, 1.00, 1.00, 
                   1.00, 1.00, 1.00, 0.00, 1.00, 0.00, 1.00, 1.00, 1.00, 1.00)

cesariana <- c(8.00, 16.00, 15.00, 23.00, 5.00, 13.00, 4.00, 19.00, 33.00, 19.00, 
               10.00, 16.00, 22.00, 2.00, 22.00, 2.00, 18.00, 21.00, 24.00, 9.00)

dados <- data.frame(
  nasc = nascimentos,
  tipohosp = tipo_hospital,
  cesarian = cesariana
)

modelo <- glm(cesarian ~ nasc,data=dados,
family=poisson(link="log"))
summary(modelo)
## 
## Call:
## glm(formula = cesarian ~ nasc, family = poisson(link = "log"), 
##     data = dados)
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 2.132e+00  1.018e-01  20.949  < 2e-16 ***
## nasc        4.406e-04  5.395e-05   8.165 3.21e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 99.990  on 19  degrees of freedom
## Residual deviance: 36.415  on 18  degrees of freedom
## AIC: 127.18
## 
## Number of Fisher Scoring iterations: 4

Questão 6

modelo2 <- glm(cesarian ~ tipohosp,data=dados,
family=poisson(link="log"))
summary(modelo2)
## 
## Call:
## glm(formula = cesarian ~ tipohosp, family = poisson(link = "log"), 
##     data = dados)
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept)   1.3863     0.2500   5.545 2.93e-08 ***
## tipohosp      1.4936     0.2569   5.814 6.11e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 99.990  on 19  degrees of freedom
## Residual deviance: 46.335  on 18  degrees of freedom
## AIC: 137.1
## 
## Number of Fisher Scoring iterations: 4

Questão 7

modelo3 <- glm(cesarian ~ nasc + tipohosp,data=dados,
family=poisson(link="log"))
summary(modelo3)
## 
## Call:
## glm(formula = cesarian ~ nasc + tipohosp, family = poisson(link = "log"), 
##     data = dados)
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 1.351e+00  2.501e-01   5.402 6.58e-08 ***
## nasc        3.261e-04  6.032e-05   5.406 6.45e-08 ***
## tipohosp    1.045e+00  2.729e-01   3.830 0.000128 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 99.990  on 19  degrees of freedom
## Residual deviance: 18.039  on 17  degrees of freedom
## AIC: 110.8
## 
## Number of Fisher Scoring iterations: 4

Questão 10

coef <- as.numeric(modelo3$coefficients)
mu <- exp(coef[1])*exp(coef[2]*1000)*exp(coef[3]*1)
mu
## [1] 15.21391