# The following statement reads the text file "NBER_BusCycles.txt" into the data set "duration.test.data", # a name that I made up that I thought was descriptive. This download is from a flash drive with e as its # directory. Sometimes if the flash drive comes up as the f drive then you will need to modify the code # below accordingly. duration.test.data<-read.table("e:\\e5375f11\\NBER_BusCycles.txt",header=T) # We attach the duration.test.data to this profram attach(duration.test.data) # For convenience we print out the names of the header variables names(duration.test.data) # Here we have R print out the data for us duration.test.data[1:33,] # Here we divide the data up into the appropriate parts con_all<-duration.test.data[1:33,1] exp_all<-duration.test.data[1:33,2] con_before<-duration.test.data[1:22,1] con_after<-duration.test.data[23:33,1] exp_before<-duration.test.data[1:22,2] exp_after<-duration.test.data[23:33,2] # The below "par" statement tests R that we want the next six histograms put on one page par(mfrow=c(3,2)) # Here we produce the 6 histograms of the various durations. They are put all on one page. hist(con_all) hist(exp_all) hist(con_before) hist(con_after) hist(exp_before) hist(exp_after) # With this option we keep the graph windows open as compared to replacing # old graphs with new graphs that are produced. windows() # Here we generate summary statistics for the variables con_all and exp_all. summary(con_all) summary(exp_all) par(mfrow=c(3,2)) # Here we produce the QQ plots that tell us the data are not normally distributed qqnorm(con_all) qqline(con_all,lty=2) # Here we use the Shapiro-Wilk test to statistically determine that the con_all series is not # normally distributed. shapiro.test(con_all) # For the next 19 lines we do the same for the variables exp_all, con_before, con_after # exp_before, and exp_after in terms of testing for their non-normality qqnorm(exp_all) qqline(exp_all,lty=2) shapiro.test(exp_all) summary(con_before) summary(con_after) qqnorm(con_before) qqline(con_before,lty=2) shapiro.test(con_before) qqnorm(con_after) qqline(con_after,lty=2) shapiro.test(con_after) summary(exp_before) summary(exp_after) qqnorm(exp_before) qqline(exp_before,lty=2) shapiro.test(exp_before) qqnorm(exp_after) qqline(exp_after,lty=2) shapiro.test(exp_after) # Here we conduct the Non-parametric Wilcox test of difference in means for the pairs # (con_all, exp_all), (con_before,con_after), and (exp_before, exp_after) wilcox.test(con_all,exp_all) wilcox.test(con_before,con_after) wilcox.test(exp_before,exp_after) # Since none of these variables are normally distributed, the below t-test are not # appropriate for testing the difference in means. I put them in there so that # you could see the syntax for t-tests were it appropriate to use them. t.test(con_all,exp_all) t.test(con_before,con_after) t.test(exp_before,exp_after)