> summary(d)
N y x f
Min. :8 Min. :0.00 Min. : 7.660 C:50
1st Qu.:8 1st Qu.:3.00 1st Qu.: 9.338 T:50
Median :8 Median :6.00 Median : 9.965
Mean :8 Mean :5.08 Mean : 9.967
3rd Qu.:8 3rd Qu.:8.00 3rd Qu.:10.770
Max. :8 Max. :8.00 Max. :12.440
> logistic <- function(z) 1 / (1 + exp(-z))
> z <- seq(-6, 6, 0.1)
> plot(z, logistic(z), type = "l")
> glm(cbind(y, N - y) ~ x + f, data = d, family = binomial)
Call: glm(formula = cbind(y, N - y) ~ x + f, family = binomial, data = d)
Coefficients:
(Intercept) x fT
-19.536 1.952 2.022
Degrees of Freedom: 99 Total (i.e. Null); 97 Residual
Null Deviance: 499.2
Residual Deviance: 123 AIC: 272.2
> library(MASS)
> stepAIC(fit.xf)
Error in terms(object) : object 'fit.xf' not found
> fit.xf <- glm(cbind(y, N - y) ~ x + f, data = d, family = binomial)
> stepAIC(fit.xf)
Start: AIC=272.21
cbind(y, N - y) ~ x + f
Df Deviance AIC
<none> 123.03 272.21
- f 1 217.17 364.35
- x 1 490.58 637.76
Call: glm(formula = cbind(y, N - y) ~ x + f, family = binomial, data = d)
Coefficients:
(Intercept) x fT
-19.536 1.952 2.022
Degrees of Freedom: 99 Total (i.e. Null); 97 Residual
Null Deviance: 499.2
Residual Deviance: 123 AIC: 272.2
> glm(cbind(y, N - y) ~ x * f, family = binomial, data = d)
Call: glm(formula = cbind(y, N - y) ~ x * f, family = binomial, data = d)
Coefficients:
(Intercept) x fT x:fT
-18.52332 1.85251 -0.06376 0.21634
Degrees of Freedom: 99 Total (i.e. Null); 96 Residual
Null Deviance: 499.2
Residual Deviance: 122.4 AIC: 273.6