La siguiente tabla muestra en número de insectos muertos después de 5 horas de exposición a gas insectMortalitybónico a distintas concentraciones. La gráfica presenta la proporción de insectos muertos (\(y_i/n_i\)) como función de la dosis.
Variable | Descripción |
---|---|
\(x_i\) | dosis |
\(n_i\) | número de insectos |
\(y_i\) | número de muertos |
dat <- insectMortality <- read.csv("../RM_tema_8/insectMortality.dat", sep="")
dim(insectMortality)
## [1] 8 3
str(insectMortality)
## 'data.frame': 8 obs. of 3 variables:
## $ x: num 1.69 1.72 1.76 1.78 1.81 ...
## $ n: int 59 60 62 56 63 59 62 60
## $ y: int 6 13 18 28 52 53 61 60
head(insectMortality)
## x n y
## 1 1.6907 59 6
## 2 1.7242 60 13
## 3 1.7552 62 18
## 4 1.7842 56 28
## 5 1.8113 63 52
## 6 1.8369 59 53
summary(insectMortality)
## x n y
## Min. :1.691 Min. :56.00 Min. : 6.00
## 1st Qu.:1.747 1st Qu.:59.00 1st Qu.:16.75
## Median :1.798 Median :60.00 Median :40.00
## Mean :1.793 Mean :60.12 Mean :36.38
## 3rd Qu.:1.843 3rd Qu.:62.00 3rd Qu.:54.75
## Max. :1.884 Max. :63.00 Max. :61.00
x <- dat$x
y <- dat$y/dat$n
mod1 <- glm(y~x, family = binomial("logit"), weights = dat$n)
print(summary(mod1))
##
## Call:
## glm(formula = y ~ x, family = binomial("logit"), weights = dat$n)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.5941 -0.3944 0.8329 1.2592 1.5940
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -60.717 5.181 -11.72 <2e-16
## x 34.270 2.912 11.77 <2e-16
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 284.202 on 7 degrees of freedom
## Residual deviance: 11.232 on 6 degrees of freedom
## AIC: 41.43
##
## Number of Fisher Scoring iterations: 4
valor-p=0.0815
mod2 <- glm(y~x, family = binomial("probit"), weights = dat$n)
print(summary(mod2))
##
## Call:
## glm(formula = y ~ x, family = binomial("probit"), weights = dat$n)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.5714 -0.4703 0.7501 1.0632 1.3449
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -34.935 2.648 -13.19 <2e-16
## x 19.728 1.487 13.27 <2e-16
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 284.20 on 7 degrees of freedom
## Residual deviance: 10.12 on 6 degrees of freedom
## AIC: 40.318
##
## Number of Fisher Scoring iterations: 4
valor-p=0.1197
mod3 <- glm(y~x, family = binomial("cloglog"), weights = dat$n)
print(summary(mod3))
##
## Call:
## glm(formula = y ~ x, family = binomial("cloglog"), weights = dat$n)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.80329 -0.55135 0.03089 0.38315 1.28883
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -39.572 3.240 -12.21 <2e-16
## x 22.041 1.799 12.25 <2e-16
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 284.2024 on 7 degrees of freedom
## Residual deviance: 3.4464 on 6 degrees of freedom
## AIC: 33.644
##
## Number of Fisher Scoring iterations: 4
valor-p=0.7519
## dosis n yobs logit probit cloglog
## 1 1.6907 59 6 3.457461 3.357774 5.58945
## 2 1.7242 60 13 9.841672 10.721610 11.28068
## 3 1.7552 62 18 22.451378 23.481932 20.95422
## 4 1.7842 56 28 33.897635 33.815505 30.36944
## 5 1.8113 63 52 50.095822 49.615626 47.77642
## 6 1.8369 59 53 53.290913 53.318874 54.14273
## 7 1.8610 62 61 59.222159 59.664650 61.11331
## 8 1.8839 60 60 58.742961 59.227967 59.94723
## Devianza.
## [1] 11.232231 10.119758 3.446439