An R Introduction to Statistics

Randomized Block Design

In a randomized block design, there is only one primary factor under consideration in the experiment. Similar test subjects are grouped into blocks. Each block is tested against all treatment levels of the primary factor at random order. This is intended to eliminate possible influence by other extraneous factors.

Example

A fast food franchise is test marketing 3 new menu items. To find out if they have the same popularity, 6 franchisee restaurants are randomly chosen for participation in the study. In accordance with the randomized block design, each restaurant will be test marketing all 3 new menu items. Furthermore, a restaurant will test market only one menu item per week, and it takes 3 weeks to test market all menu items. The testing order of the menu items for each restaurant is randomly assigned as well.

Problem

Suppose each row in the following table represents the sales figures of the 3 new menu in a restaurant after a week of test marketing. At .05 level of significance, test whether the mean sales volume for the 3 new menu items are all equal.

 Item1 Item2 Item3 
    31    27    24 
    31    28    31 
    45    29    46 
    21    18    48 
    42    36    46 
    32    17    40

Solution

The solution consists of the following steps:

  1. Copy and paste the sales figure above into a table file named "fastfood-2.txt" with a text editor.
  2. Load the file into a data frame named df2 with the read.table function. As the first line in the file contains the column names, we set the header argument as TRUE.
    > df2 = read.table("fastfood-2.txt", header=TRUE); df2 
      Item1 Item2 Item3 
    1    31    27    24 
    2    31    28    31 
    3    45    29    46 
    4    21    18    48 
    5    42    36    46 
    6    32    17    40
  3. Concatenate the data rows in df2 into a single vector r .
    > r = c(t(as.matrix(df2))) # response data 
    > r 
     [1] 31 27 24 31 28 ...
  4. Assign new variables for the treatment levels and number of control blocks.
    > f = c("Item1", "Item2", "Item3")   # treatment levels 
    > k = 3                    # number of treatment levels 
    > n = 6                    # number of control blocks
  5. Create a vector of treatment factors that corresponds to the each element in r of step 3 with the gl function.
    > tm = gl(k, 1, n*k, factor(f))   # matching treatment 
    > tm 
     [1] Item1 Item2 Item3 Item1 Item2 ...
  6. Similarly, create a vector of blocking factors for each element in the response data r.
    > blk = gl(n, k, k*n)             # blocking factor 
    > blk 
     [1] 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 
    Levels: 1 2 3 4 5 6
  7. Apply the function aov to a formula that describes the response r by both the treatment factor tm and the block control blk.
    > av = aov(r ~ tm + blk)
  8. Print out the ANOVA table with the summary function.
    > summary(av) 
                Df Sum Sq Mean Sq F value Pr(>F) 
    tm           2    539     269    4.96  0.032 * 
    blk          5    560     112    2.06  0.155 
    Residuals   10    543      54

Answer

Since the p-value of 0.032 is less than the .05 significance level, we reject the null hypothesis that the mean sales volume of the new menu items are all equal.

Exercise

Create the response data in step 3 above along vertical columns instead of horizontal rows. Adjust the factor levels in steps 5 and 6 accordingly.