R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" Copyright (C) 2015 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > # we do example 9.2.4 in Agresti > > udata <- read.table("http://www.stat.umn.edu/geyer/5421/data/table-9.3.txt", + header = TRUE) > udata a c m count 1 Yes Yes Yes 911 2 Yes Yes No 538 3 Yes No Yes 44 4 Yes No No 456 5 No Yes Yes 3 6 No Yes No 43 7 No No Yes 2 8 No No No 279 > > gout <- glm(count ~ a * c * m, data = udata, family = poisson) > summary(gout) Call: glm(formula = count ~ a * c * m, family = poisson, data = udata) Deviance Residuals: [1] 0 0 0 0 0 0 0 0 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) 5.63121 0.05987 94.060 < 2e-16 *** aYes 0.49128 0.07601 6.464 1.02e-10 *** cYes -1.87001 0.16383 -11.414 < 2e-16 *** mYes -4.93806 0.70964 -6.959 3.44e-12 *** aYes:cYes 2.03538 0.17576 11.580 < 2e-16 *** aYes:mYes 2.59976 0.72698 3.576 0.000349 *** cYes:mYes 2.27548 0.92746 2.453 0.014149 * aYes:cYes:mYes 0.58951 0.94236 0.626 0.531600 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 2.8515e+03 on 7 degrees of freedom Residual deviance: -1.2590e-13 on 0 degrees of freedom AIC: 65.043 Number of Fisher Scoring iterations: 3 > > stout <- step(gout) Start: AIC=65.04 count ~ a * c * m Df Deviance AIC - a:c:m 1 0.37399 63.417 0.00000 65.043 Step: AIC=63.42 count ~ a + c + m + a:c + a:m + c:m Df Deviance AIC 0.37 63.42 - a:m 1 92.02 153.06 - a:c 1 187.75 248.80 - c:m 1 497.37 558.41 > summary(stout) Call: glm(formula = count ~ a + c + m + a:c + a:m + c:m, family = poisson, data = udata) Deviance Residuals: 1 2 3 4 5 6 7 8 0.02044 -0.02658 -0.09256 0.02890 -0.33428 0.09452 0.49134 -0.03690 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) 5.63342 0.05970 94.361 < 2e-16 *** aYes 0.48772 0.07577 6.437 1.22e-10 *** cYes -1.88667 0.16270 -11.596 < 2e-16 *** mYes -5.30904 0.47520 -11.172 < 2e-16 *** aYes:cYes 2.05453 0.17406 11.803 < 2e-16 *** aYes:mYes 2.98601 0.46468 6.426 1.31e-10 *** cYes:mYes 2.84789 0.16384 17.382 < 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 2851.46098 on 7 degrees of freedom Residual deviance: 0.37399 on 1 degrees of freedom AIC: 63.417 Number of Fisher Scoring iterations: 4 > > > proc.time() user system elapsed 0.141 0.011 0.266