Chapter 3, Displaying and Describing Catagorical Data

Homework 3.3 Problem 33

Anorexia <- matrix(c(35,32,14,12),ncol=2,byrow=TRUE)
colnames(Anorexia) <- c("Prozac","Placebo")

rownames(Anorexia) <- c("Healthy","Relapse")
Anorexia <- as.table(Anorexia)
Anorexia
##         Prozac Placebo
## Healthy     35      32
## Relapse     14      12

CrossTable from the gmodels package does all these at once.

library(gmodels)
as.data.frame.matrix(Anorexia)
##         Prozac Placebo
## Healthy     35      32
## Relapse     14      12
CrossTable(Anorexia, prop.t=TRUE, prop.r=TRUE, prop.c=TRUE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## | Chi-square contribution |
## |           N / Row Total |
## |           N / Col Total |
## |         N / Table Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  93 
## 
##  
##              |  
##              |    Prozac |   Placebo | Row Total | 
## -------------|-----------|-----------|-----------|
##      Healthy |        35 |        32 |        67 | 
##              |     0.003 |     0.003 |           | 
##              |     0.522 |     0.478 |     0.720 | 
##              |     0.714 |     0.727 |           | 
##              |     0.376 |     0.344 |           | 
## -------------|-----------|-----------|-----------|
##      Relapse |        14 |        12 |        26 | 
##              |     0.007 |     0.007 |           | 
##              |     0.538 |     0.462 |     0.280 | 
##              |     0.286 |     0.273 |           | 
##              |     0.151 |     0.129 |           | 
## -------------|-----------|-----------|-----------|
## Column Total |        49 |        44 |        93 | 
##              |     0.527 |     0.473 |           | 
## -------------|-----------|-----------|-----------|
## 
## 
  1. It appears that Prozac didn’t work to cure anorexia. This is shown in the data where the Placebo actually had higher rates of sucsess at 72.7% healthy versus the Prozac, which only had a sucsess rate of 71.4%.

Some graphs…

Healthy is blue, relapse is red

barplot(Anorexia, main = "Prozac vs Placebo", col=c("darkblue","red"), beside = T)