# Author: Adolfo J. Rumbos # Date: 9/3/2008 # # This R code performs a randomization test on a subset of the Westvaco # data found on page 5 of Statistics in Action by Watkins, Sheaffer and # Cobb. # # The subset consists of the 10 hourly workers involved the second of # the five rounds of layoffs. Three of the 10 workers were laid off # in that round. # # The 10 hourly workers involved in the 2nd round of layoffs are entered into # a vector called hourly2 # hourly2 <- c(25,38,56,48,55,64,55,55,33,35) Nsamples <- 1000 # Nsamples is the number of samples drawn # # Nsamples random samples of size 3, without replacement, # from hourly2 and their averages are computed and stored in a vector # denoted Xbar # Xbar <- mean(sample(hourly2,3,replace=F)) # sets initial value of x_bar l <- Nsamples -1 # we need Nsamples - 1 more samples for (i in 1:l) # Sets up a loop from 1 to Nsamples { # Begins body of loop Xbar <- c(Xbar, mean(sample(hourly2,3,replace=F))) # creates vector of average ages of laid off workers } # End of loop