# # This file contains R commands that reproduce the analyses # presented in Chapter 6 # # Read data on peak expiratory flow (PEF) from clinical trial to compare # two drug-treatments for chronic asthma # asthma<-read.table("../data/asthma.data",header=T) # # Scatterplot of paired values of PEF # F<-asthma$F S<-asthma$S pdf(file="asthmascatterplot.pdf",paper="special",height=6,width=6) par(pty="s") plot(F,S,xlim=c(0,420),ylim=c(0,420),cex.lab=1.5,cex.axis=1.5,pch=19) lines(c(0,420),c(0,420),lty=2) dev.off() # # Dotplot of unpaired values of PEF # F<-asthma$F S<-asthma$S pdf(file="asthmadotplot.pdf",paper="special",height=3,width=6) plot(F,rep(0.25,length(F)),xlim=c(0,420),ylim=c(0,1),cex.lab=1.5,cex.axis=1.5,pch="F",xlab="PEF",ylab=" ", bty="n",yaxt="n") points(S,rep(0.75,length(S)),pch="S") dev.off() # # Analysis of the data according to the (correct) paired design (Section 6.3.1) # F<-asthma$F S<-asthma$S D<-F-S Dbar<-mean(D) n<-length(D) s2<-var(D) SE<-sqrt(s2/n) CI<-Dbar+c(-2,2)*SE # # Analysis of the data according to the (incorrect) parallel group design (Section 6.3.2) # Fbar<-mean(F) sF<-sqrt(var(F)) Sbar<-mean(S) sS<-sqrt(var(S)) s2pooled<-(sF*sF+sS*sS)/2 CI<-(Fbar-Sbar) + c(-2,2)*sqrt(2*s2pooled/n) # # Analysis of the data according to the (correct) crossover design - a refinement of the # paired design (Section 6.4) # Dbar1<-mean(D[1:7]) Dbar2<-mean(D[8:13]) # # Scatterplot of the data, showing clear difference between treatments, in favour of Formoterol # pdf(file="sol2.pdf",height=6,width=8) par(pty="s") plot(F,S,pch=19,cex=1,xlim=c(0,420),ylim=c(0,420),cex.lab=1.5,cex.axis=1.5) lines(c(0,420),c(0,420),lty=2) dev.off()