R Programs

Some Helpful Resources

The Topic / Procedure Page
R code - text data file
Different chi-squared distributions   chisqdistributions.R
Binomial Likelihood  
Simple Binomial Calculations in R 2.3.2
Basic Poisson Calculations in R 2.3.1

Goodness-of-Fit Test: Cell Probabilities Functions of Unknown Parameters

Creates a table of one-way frequencies for observations of a die and then finds calculates a one-way chi-square test 2.5
Binomial test of proportions 2.3.2
Poisson sampling and goodness of fit with one-way table
Datafile: soccer2002.txt
Goodness of fit with X2 with G2 2.5
Test of independence, and measures of associations for a 2 × 2 table 3.1.5
Test of independence, and measures of associations for an I × J table



Test of independence, and measures of associations for an I × J table; simple data visualization 3.2.3
Enters tea tasting data and performs one-sided and two-side Fisher's exact test for count data. 3.3
Enters the voters data and performs McNemar's test for 2 × 2 tables 4.2.3
Cohen's kappa 4.2.5
Takes the marginal counts specified for by each parameter and using these to estitmate the contents of a specific cell. This is used to test for mutual independence. Also for other independence models. 5.3
Test for various independence models in a 3-way table 5.4.1

Tests for various independence models in a 3-way table (Datafile: berkeley.txt)

Loglinear models

Simpson's paradox

Logistic Regression for 2-way tables 6.2.2
Logistic Regression for 3-way tables 6.3.1
Logistic Regression with continuous covariates 7.1.1
ROC analysis, plot the ROC curve and a Hosmer-Lemeshow test 7.1.1 ROCandHL.R

CASE STUDY: The Water Level Study
Logistic Regression Analyses

Water Level Study 2 (.doc)
Model Selection: Backward & Stepwise Procedures



Datafile: water_level.txt

Logistic regression 7.2.1
Baseline-category logit model 8.2.2



Proportional-odds cumulative logit model 8.4.1 cheese.dat
Proportional-odds cumulative logit model
Datafile: abortion.txt
8.4.2 abortion.r
Poisson Regression 9.2
Poisson Regression with rates
Datafile: creditcard.txt
CASE STUDY: The Ice Cream Study at Penn State  

CASE STUDY: Stress and Smoking

Datafile: stress.txt

Loglinear models for 2 × 2 tables 10.1.2 VitaminCLoglin.R
Loglinear model of independence for two-way table 10.1.3 vote.R
Loglinear models 3-way tables 10.2 berkeleyLoglin.R

Loglinear models; model assessment and selection
Datafile: collar.txt

10.2.9 collar.out
Sparse data: Sampling & Structural Zeros 11.1.1 ZerosEx.R
Sparse data: Incomplete table analysis 11.1.3 health.R
Ordinal data: Linear by linear association model 11.2.1 HeartDiseaseLoglin.R
Dependent data: loglinear models 11.3.2 movies.R
Dependent data: quasi-independence loglinear model 11.3.5 monkey.R