# Example 2.1 (Table 2.1) in Davis, 2002 temp <- c(-10,25,37,50,65,80) m <- matrix(scan("e:\\vhm\\vhm882\\data\\deal.dat"),ncol=7,byrow=T) subject <- m[,1] y <- m[,2:7] slope <- c() for (i in 1:8) slope=c(slope,coef(lm(y[i,]~temp))[2]) names(slope) <- NULL t.test(slope) # one-sample t-test for slopes wilcox.test(slope) # one-sample Wilcoxon signed rank test for slopes # method 2 rankcorr <- c() for (i in 1:8) rankcorr=c(rankcorr,cor.test(temp,y[i,],method=c("spearman"))$estimate) names(rankcorr) <- NULL wilcox.test(rankcorr) # one-sample Wilcoxon signed rank test for rank correlations binom.test(sum(rankcorr>0),length(rankcorr)) # one-sample sign test for rank correlations # code for graphics, using nlme library library(nlme) deal <- balancedGrouped( y ~ temp|subject, matrix(m[,2:7],nrow=8,ncol=6,dimnames=list(subject,temp)), labels=list(y="Ventilation volume at different temperatures")) p1 <- plot(deal) p1 # screen plot ps.options(horizontal=FALSE,onefile=FALSE,print.it=FALSE) # p.75 in VR library(lattice) trellis.device("postscript",file="c:\\data.avc\\teaching\\vhm882\\01l\\d_eg2_1.eps") p1 # file plot dev.off()