# Categorical Data Analysis

```> library("TeachingDemos")
> n <- 12
> y <- 7
> a <- 1
> b <- 1
> h <- hpd(qbeta, shape1=y+a, shape2=n-y+b)
> h
[1] 0.3232160 0.8144068```
```> # compare to equal tailed:
> qbeta(c(0.025,0.975), shape1=y+a, shape2=n-y+b)
[1] 0.3157776 0.8077676```
•  Homework 3 (due next week Friday; final version with one more problem added and one typo in exercise 2 corrected; thanks to some of you for pointing this out):HW3
• Solutions to HW 2 (updated!!): Solution_HW2
• Solutions to Homework 3
• Inverting score tests for inference on difference of two independent proportions: Overview
• R code to get the score confidence interval for the difference of two independent binomial proportions: score_int_diff_2props
• R code for the exact confidence interval for the difference of two independent proportions:AgrestiMin (needs to be updated)
• Handout: Chi-squared tests
• Some Historical Notes: Controversies about odds ratio or degrees of freedom (Pearson vs. Yule or Fisher)
• Permutation Test for two-way contingency tables: Permutation tests for independence in general r x c tables
• Homework 4 (due next Thursday!): HW4
• Practice for the final exam: Quiz1
• Fisher’s Exact Test online.
• General Permutation test of independence online (using Monte Carlo sampling)
• GEE analysis of cross-over trial (see lecture notes) with high and low dose:
```subj <- rep(1:86,each=2)
dose <- rep(c(1,0),86) # 1 means high, 0 means low
resp <- c(rep(c(1,1),53),rep(c(1,0),16),rep(c(0,1),8),rep(c(0,0),9)) #from contingency table counts
mydat <- data.frame(subj=subj,dose=dose,resp=resp)
require("gee") #Fit GEE model with exchangeable working correlation structure
fit_exch <- gee(resp~dose, family=binomial,id=subj, data=mydat ,corstr = "exchangeable")
summary(fit_exch)```

• Space shuttle data set: challenger
• Wiki entry of the Challenger disaster
• Horseshoe Crab data: crabHomework 4: HW4
• Multinomial Response Models:
• Alligator data set: alligator
• R code to fit baseline category model: alli
• Pneumonia in coalminers data set:coalminers
• R code for cumulative logit models: Rcode_coalminers
• Another cumulative logit model: Mental depression
• Data Set (as .txt file): mental
• Annotated R code (using packages vglm or ordinal): CumLogit
• Loglinear Models:
•  For Contingency Tables: Alc-Cig-Mar use: alccigmar
• Not covered: Models for repeated binary observationsHomework 5: HW5
• Final Exam (due next Friday):