36  Random plot generator

Author

Andres Patrignani

Published

January 18, 2024

One of the most common tasks when designing a new research experiment is the randomization of treatments. This statistical procedure spans multiple disciplines, from field plots in agronomy to Petri dishes in microbiology. The idea of setting a proper experiment design is to ensure that differences in the observed variable are mostly due to treatment effects and not other factors.

There are multiple experimental designs, but the three of the most popular are complete randomized design, randomized complete block design, and Latin square design.

Complete randomized design: In a completely randomized design (CRD), treatments are allocated entirely at random, ensuring that each experimental unit has an equal probability of receiving any given treatment. This design is particularly effective in homogeneous conditions where each unit is expected to respond similarly to treatments. In CRD, it is possible for the same treatment to be repeated across different units within the same replication. The assumption of homogeneous conditions enables any treatment to be assigned to any experimental unit without bias.

Randomized complete block design: Unlike CRD, in a randomized complete block design (RCBD), the primary goal is to minimize experimental error by accounting for known sources of variability among experimental units, such as terrain slope, temperature gradients in greenhouses, or varying light conditions. This is achieved by grouping similar experimental units into “blocks” that are expected to respond uniformly to treatments. Within each block, treatments are randomly assigned in such a way that each treatment appears exactly once. This ensures that the effect of each treatment can be assessed independently of block-to-block variation, enhancing the evaluation of treatment effects.

Latin square design: The Latin square design is used to control for two sources of variation in experimental setups. In this design, each treatment appears exactly once in each row and each column of the square, akin to a Latin puzzle, hence the name. For example, if there are five treatments, they will be arranged in a 5x5 square. This setup ensures that the effects of row and column variables are evenly distributed, reducing experimental error and isolating the treatment effects more effectively. The Latin square design is an efficient way to handle two-dimensional heterogeneity in experimental designs in controlled studies (e.g., greenhouse studies).

The goal of this exercise is to create a Python script that generates randomized plot labels given a list of treatments and number of replications.

# Import modules
import numpy as np
# Define treatments and replicates
treatments = np.array(["N0", "N25", "N50", "N100", "N200"]) # Nitrogen in kg N/hectare

# Define number replicates
replicates = 5

Complete randomized design

# Randomized complete block
np.random.seed(1)

# Create the experimental units
exp_units_crd = np.repeat(treatments, replicates)

# Randomize the order of the experimental units (inplace operation)
np.random.shuffle(exp_units_crd)

# Divide array into individual replicates for easier reading
exp_units_crd = np.reshape(exp_units_crd, (replicates,treatments.shape[0]))
print(exp_units_crd)
[['N50' 'N50' 'N100' 'N0' 'N200']
 ['N50' 'N100' 'N100' 'N0' 'N0']
 ['N200' 'N25' 'N25' 'N200' 'N0']
 ['N100' 'N0' 'N100' 'N200' 'N200']
 ['N25' 'N25' 'N50' 'N50' 'N25']]

Complete randomized block

# Complete randomized
np.random.seed(1)

# Create array of experimental units
# In field experiments it is common to keep the first block sorted
# to have as a reference during field visits. This is not a problem
# since the sorted array is one of the possible block arrangements
exp_units_rcbd = treatments

for i in range(replicates-1):
    
    # Draw treatments without replacement
    block = np.random.choice(treatments, size=treatments.size, replace=False)
    exp_units_rcbd = np.vstack((exp_units_rcbd, block))

print(exp_units_rcbd)
[['N0' 'N25' 'N50' 'N100' 'N200']
 ['N50' 'N25' 'N200' 'N0' 'N100']
 ['N0' 'N50' 'N200' 'N100' 'N25']
 ['N50' 'N100' 'N25' 'N200' 'N0']
 ['N100' 'N0' 'N25' 'N50' 'N200']]

Latin square design

# Latin square
np.random.seed(1)

# Create experimental units, all rows with the same treatments
exp_units_latsq = np.tile(treatments,replicates).reshape((replicates,treatments.size))

# Create array with random shift steps
shifts = np.random.choice(range(replicates), size=replicates, replace=False)

for n,k in enumerate(shifts):
    
    # Shift first block by a random step
    exp_units_latsq[n] = np.roll(exp_units_latsq[n], k)

print(exp_units_latsq)
[['N100' 'N200' 'N0' 'N25' 'N50']
 ['N200' 'N0' 'N25' 'N50' 'N100']
 ['N25' 'N50' 'N100' 'N200' 'N0']
 ['N0' 'N25' 'N50' 'N100' 'N200']
 ['N50' 'N100' 'N200' 'N0' 'N25']]

Practice

  • Practice by coding other experimental designs, like split-plot design.

References

Jayaraman, K., 1984. FORSPA-FAO Publication A Statistical Manual for forestry Research (No. Fe 25). FAO,. http://www.fao.org/3/X6831E/X6831E07.htm