next up previous
Next: Graphics for display Up: Software for Statistical Analysis Previous: R Notes

Examples

Anorexia. The file
http://www.utdallas.edu/~ammann/stat3355scripts/anorexia.txt
contains pre-treatment and post-treatment weights of anorexia patients. These patients were randomly assigned to one of three treatments, Cont, CBT, FT. We would like to show a comparison of pre-treatment weights. We also would like to show how patient weight gains compared across these treatments with weight gain expressed as a percentage increase from pre-treatment.

Anorexia = read.table("http://www.utdallas.edu/~ammann/stat3355scripts/anorexia.txt",
   header=TRUE, row.names=1)
Trtcol = c("blue","IndianRed","green")
plot(Prewt ~ Treat, data=Anorexia,xlab="Treatment",ylab="Weight",col=Trtcol)
n = dim(Anorexia)[1]
title(paste("Pre-treatment Weight of",n,"Anorexia Patients"))
Wtgain = Anorexia[,"Postwt"]-Anorexia[,"Prewt"]
Wtgainpc = 100*Wtgain/Anorexia[,"Prewt"]
plot(Wtgainpc ~ Treat, data=Anorexia,xlab="Treatment",ylab="Weight gain %",col=Trtcol)
title(paste("Relative Weight Gain of",n,"Anorexia Patients"))
#note that CBT has 6 observations that are unusually high.

Consider all patients who lost weight during the study. Determine the number of such patients in each treatment group.

table(Anorexia[,"Treat"],Wtgain < 0)

Next consider those patients in the upper 25% of percentage weight gain. Determine the number of such patients in each treatment group.

uq = quantile(Wtgainpc,.75)
table(Anorexia[,"Treat"],Wtgain >= uq)



Larry Ammann
2014-09-30