## BERD R Short Course ## Session 4 Homework Key ##1 y1<-rnorm(100) y2<-rnorm(100,mean=1,sd=sqrt(3)) #(a) s1<-summary(y1) v1<-var(y1) s2<-summary(y2) v2<-var(y2) #(b) var.test(y1,y2) #(c) t.test(y1,y2) ##2 y1<-rnorm(100) y2<-rchisq(100,df=3) #(a) cov(y1,y2) cor(y1,y2) cor.test(y1,y2) #(b) shapiro.test(y1) shapiro.test(y2) #(c) ks.test(y1,y2) ##3 library(MASS) #(a) tb<-table(survey$Sex,survey$Smoke) #(b) chisq.test(tb) fisher.test(tb) ##4 #a pwr.t.test(d=0.2,power=0.8,sig.level=0.05,type="two.sample",alternative="greater")