13.11.2012 Views

Introduction to Categorical Data Analysis

Introduction to Categorical Data Analysis

Introduction to Categorical Data Analysis

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

334 APPENDIX A: SOFTWARE FOR CATEGORICAL DATA ANALYSIS<br />

Table A.2. SAS Code for Fisher’s Exact Test and Confidence Intervals for Odds<br />

Ratio for Tea-Tasting <strong>Data</strong> in Table 2.8<br />

data fisher;<br />

input poured guess count ©©;<br />

datalines;<br />

1 1 3 1 2 1 2 1 1 2 2 3<br />

;<br />

proc freq; weight count;<br />

tables poured*guess / measures riskdiff;<br />

exact fisher or / alpha=.05;<br />

odds ratio (labeled “case-control” on output) and the relative risk, and the RISKDIFF<br />

option provides intervals for the proportions and their difference. For tables having<br />

small cell counts, the EXACT statement can provide various exact analyses. These<br />

include Fisher’s exact test and its generalization for I × J tables, treating variables as<br />

nominal, with keyword FISHER. The OR keyword gives the odds ratio and its largesample<br />

and small-sample confidence intervals. Other EXACT statement keywords<br />

include binomial tests for 1 × 2 tables (keyword BINOMIAL), exact trend tests for<br />

I × 2 tables (TREND), and exact chi-squared tests (CHISQ) and exact correlation<br />

tests for I × J tables (MHCHI).<br />

CHAPTER 3: GENERALIZED LINEAR MODELS<br />

PROC GENMOD fits GLMs. It specifies the response distribution in the DIST option<br />

(“poi” for Poisson, “bin” for binomial, “mult” for multinomial, “negbin” for negative<br />

binomial) and specifies the link in the LINK option. Table A.3 illustrates for binary<br />

regression models for the snoring and heart attack data of Table 3.1. For binomial<br />

grouped data, the response in the model statements takes the form of the number<br />

of “successes” divided by the number of cases. Table A.4 fits Poisson and negative<br />

binomial loglinear models for the horseshoe crab data of Table 3.2.<br />

Table A.3. SAS Code for Binary GLMs for Snoring <strong>Data</strong> in Table 3.1<br />

data glm;<br />

input snoring disease <strong>to</strong>tal ©©;<br />

datalines;<br />

0 24 1379 2 35 638 4 21 213 5 30 254<br />

;<br />

proc genmod; model disease/<strong>to</strong>tal = snoring / dist=bin link=identity;<br />

proc genmod; model disease/<strong>to</strong>tal = snoring / dist=bin link=logit;<br />

PROC GAM fits generalized additive models. These can smooth data, as illustrated<br />

by Figure 3.5.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!