
R (and S-PLUS) Manual to Accompany Agresti’s Categorical Data Analysis (2002) 2nd edition Laura A. Thompson, 2008© Table of Contents Introduction and Changes from First Edition .....................1 A. Obtaining the R Software for Windows.................................................................... 1 B. Libraries in S-PLUS and Packages in R.................................................................. 1 C. Setting contrast types using Options() .................................................................... 3 D. Credit for functions.................................................................................................. 3 E. Editing functions...................................................................................................... 3 F. A note about using Splus Menus............................................................................. 4 G. Notice of errors ....................................................................................................... 4 H. Introductions to the S Language ............................................................................. 4 I. References ............................................................................................................... 4 J. Acknowledgements.................................................................................................. 5 Chapter 1: Distributions and Inference for Categorical Data: ..................................................................................6 A. Summary of Chapter 1, Agresti .............................................................................. 6 B. Categorical Distributions in S-PLUS and R ............................................................ 6 C. Proportion of Vegetarians (Statistical Inference for Binomial Parameters)............. 8 D. The Mid-P-Value .................................................................................................. 11 E. Pearson’s Chi-Squared Statistic........................................................................... 11 F. Likelihood Ratio Chi-Squared Statistic ................................................................. 12 G. Maximum Likelihood Estimation........................................................................... 12 Chapter 2: Describing Contingency Tables .....................16 A. Summary of Chapter 2, Agresti ............................................................................. 16 B. Comparing two proportions ................................................................................... 18 C. Partial Association in Stratified 2 x 2 Tables ......................................................... 19 D. Conditional Odds Ratios ....................................................................................... 23 E. Summary Measures of Assocation: Ordinal Trends .............................................. 24 Chapter 3: Inference for Contingency Tables..................28 A. Summary of Chapter 3, Agresti ............................................................................. 28 B. Confidence Intervals for Association Parameters.................................................. 29 C. Testing Independence in Two-way Contingency Tables ....................................... 35 D. Following Up Chi-Squared Tests........................................................................... 37 E. Two-Way Tables with Ordered Classification........................................................ 39 F. Small Sample Tests of Independence ................................................................... 41 G. Small-Sample Confidence Intervals For 2x2 Tables ............................................. 44 Chapter 4: Generalized Linear Models............................50 A. Summary of Chapter 4, Agresti ............................................................................. 50 i B. Generalized Linear Models for Binary Data........................................................... 51 C. Generalized Linear Models for Count Data ........................................................... 56 D. Overdispersion in Poisson Generalized Linear Models......................................... 61 E. Negative Binomial GLIMs...................................................................................... 63 F. Residuals for GLIMs.............................................................................................. 65 G. Quasi-Likelihood and GLIMs................................................................................. 67 H. Generalized Additive Models (GAMs) ................................................................... 68 Chapter 5 : Logistic Regression.......................................72 A. Summary of Chapter 5, Agresti ............................................................................ 72 B. Logistic Regression for Horseshoe Crab Data ..................................................... 73 C. Goodness-of-fit for Logistic Regression for Ungrouped Data............................... 77 D. Logit Models with Categorical Predictors ............................................................. 78 E. Multiple Logistic Regression................................................................................. 82 F. Extended Example (Problem 5.17)....................................................................... 88 Chapter 6 – Building and Applying Logistic Regression Models .............................................................................92 A. Summary of Chapter 6, Agresti ............................................................................. 92 B. Model Selection..................................................................................................... 93 C. Using Causal Hypotheses to Guide Model Fitting................................................. 94 D. Logistic Regression Diagnostics ........................................................................... 96 E. Inference about Conditional Associations in 2 x 2 x K Tables ............................. 102 F. Estimation/Testing of Common Odds Ratio......................................................... 105 G. Using Models to Improve Inferential Power ........................................................ 106 H. Sample Size and Power Considerations ............................................................. 107 I. Probit and Complementary Log-Log Models ....................................................... 109 J. Conditional Logistic Regression and Exact Distributions ..................................... 111 K. Bias-reduced Logistic Regression ....................................................................... 116 Chapter 7 –Logit Models for Multinomial Responses ....117 A. Summary of Chapter 7, Agresti ........................................................................... 117 B. Nominal Responses: Baseline-Category Logit Models........................................ 118 C. Cumulative Logit Models..................................................................................... 121 D. Cumulative Link Models ...................................................................................... 125 E. Adjacent-Categories Logit Models....................................................................... 127 F. Continuation-Ratio Logit Models.......................................................................... 128 G. Mean Response Models ..................................................................................... 134 H. Generalized Cochran-Mantel Haenszel Statistic for Ordinal Categories ............ 139 Chapter 8 –Loglinear Models for Contingency Tables ..141 A. Summary of Chapter 8, Agresti ........................................................................... 141 B. Loglinear Models for Three-way Tables .............................................................. 142 C. Inference for Loglinear Models............................................................................ 145 ii D. Loglinear Models for Higher Dimensions ........................................................... 147 E. Loglinear-Logit Model Connection....................................................................... 150 F. Contingency Table Standardization..................................................................... 151 Chapter 9 –Building and Extending Loglinear Models...152 A. Summary of Chapter 9, Agresti ........................................................................... 152 B. Model Selection and Comparison....................................................................... 153 C. Diagnostics for Checking Models....................................................................... 155 D. Modeling Ordinal Assocations............................................................................ 156 E. Assocation Models .............................................................................................. 158 F. Association Models, Correlation Models, and Correspondence Analysis ............ 164 G. Poisson Regression for Rates............................................................................. 170 H. Modeling Survival Times ..................................................................................... 172 I. Empty Cells and Sparseness................................................................................ 174 Chapter 10 – Models for Matched Pairs ........................176 A. Summary of Chapter 10, Agresti ........................................................................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages280 Page
-
File Size-