Split-Plot ANOVA in R: Mean Comparisons and Interaction Plots

See Video ⮞ ☝


This tutorial analyzes a split-plot experiment, performs factor-specific mean comparisons, and displays treatment means. The essential point is that whole-plot and subplot factors have different randomization and error strata; the model and comparisons must preserve that structure.

Description of design

In a split-plot design, one factor is randomized to whole plots within blocks, and a second factor is randomized to subplots within each whole plot. Whole plots act as blocks for the subplot treatments, producing distinct error terms for the two main effects and their interaction.

For the rice example, variety is assigned to main plots and seedling age to subplots within each of three blocks. The subplot factor is randomized independently within each main plot. This layout is not equivalent to a factorial RCBD with all six combinations randomized as whole plots.

Block1
Block2
V1
V2
V2
V1
Layout split plot design
V1A1 V2A2 V2A1 V1A3
V1A3 V2A1 V2A2 V1A2
V1A2 V2A3 V2A3 V1A1

Each block contains the two varieties and all three seedling ages, but the six combinations are not independently randomized at the same plot size. That distinction determines the correct ANOVA error terms.

Split-plot designs are often called incomplete block designs.

Import data file

The experiment compares two rice varieties and seedling ages of two, three, and four weeks in a split-plot RCBD with three replications. Confirm the actual field randomization and plot map before using this analysis.

The outcome is days from heading to maturity. Save any existing workspace objects before clearing them; console or graphics cleanup is optional.

rm(list = ls(all = TRUE))
graphics.off()
shell("cls")

Import the CSV file with the correct path and header setting. Check that the data contain the block, main-plot factor, subplot factor, and response for each experimental unit.

Set header = TRUE when the first row contains variable names. Inspect initial rows and verify the treatment labels and replication counts.

data <- read.csv(file = "data_split.csv", 
                 header = TRUE)
head(data)
#   block     var age heading
# 1     1   Super  2W      89
# 2     1   Super  3W      94
# 3     1   Super  4W      96
# 4     1 Shaheen  2W      75
# 5     1 Shaheen  3W      80
# 6     1 Shaheen  4W      84

Observe variables

Use str() to confirm that block, variety, and seedling age are categorical and the response is numeric. Convert labels to factors if required, preserving their intended order.

data$var = as.factor(data$var)
data$age = as.factor(data$age)
str(data)
# 'data.frame': 26 obs. of  4 variables:
#  $ block  : int  1 1 1 1 1 1 2 2 2 2 ...
#  $ var    : Factor w/ 3 levels "","Shaheen","Super": 3 3 3 2 2 2 3 3 3 2 ...
#  $ age    : Factor w/ 4 levels "","2W","3W","4W": 2 3 4 2 3 4 2 3 4 2 ...
#  $ heading: int  89 94 96 75 80 84 85 99 101 72 ...
attach(data)

Fit analysis of variance model

Load agricolae after installation if necessary. Confirm the package version and function arguments used in the current workflow.

Fit the model with sp.plot(), supplying the block, main-plot factor, subplot factor, and response correctly. The factor roles must match the field randomization; changing the argument labels does not change the design.

Inspect the ANOVA output and its separate error strata. Use the correct denominator for each main effect and interaction, and review residual behavior before interpreting tests.

library(agricolae)
attach(data)
# The following objects are masked from data (pos = 4):
# 
#     age, block, heading, var
model <- sp.plot(block = block, 
                 pplot = var, 
                 splot = age, 
                 Y = heading)
# 
# ANALYSIS SPLIT PLOT:  heading 
# Class level information
# 
# var   :  Super Shaheen  
# age   :  2W 3W 4W  
# block     :  1 2 3 4 NA 
# 
# Number of observations:  26 
# 
# Analysis of Variance Table
# 
# Response: heading
#         Df  Sum Sq Mean Sq F value    Pr(>F)    
# block    3   28.46    9.49  0.4415   0.74034    
# var      1 1365.04 1365.04 63.5314   0.00412 ** 
# Ea       3   64.46   21.49                      
# age      2  641.33  320.67 44.5714 2.789e-06 ***
# var:age  2   16.33    8.17  1.1351   0.35359    
# Eb      12   86.33    7.19                      
# ---
# Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# 
# cv(a) = 5.4 %, cv(b) = 3.1 %, Mean = 85.45833

The example reports significant main effects and a non-significant interaction. Interpret the main effects in light of the interaction estimate and its uncertainty. A non-significant interaction is not proof of no interaction, and unplanned comparisons of the interaction should not be treated as confirmatory.

Mean separation test

Get error df and error MS values

Extract error degrees of freedom and mean squares separately for the whole-plot, subplot, and interaction terms. Verify these values against the model output before passing them to a comparison function.

# Get first error df
Edf_a <- model$gl.a
Edf_a
# Get second error df
Edf_b <- model$gl.b
Edf_b
# Get first error MS
EMS_a <- model$Ea
EMS_a
# Get second error MS
EMS_b <- model$Eb
EMS_b
# [1] 3
# [1] 12
# [1] 21.48611
# [1] 7.194444

LSD test on main effects

For the main-plot factor, use its own error degrees of freedom and mean square. The response and treatment labels should correspond to the fitted model.

Set the significance level explicitly, for example alpha = 0.05. State the multiple-comparison procedure and adjustment. Fisher’s LSD is relatively liberal when many pairwise comparisons are made.

out1 <- LSD.test(y = heading, 
                 trt = var,
                 DFerror = Edf_a, 
                 MSerror = EMS_a,
                 alpha = 0.05,
                 p.adj = "bonferroni",
                 group = TRUE,
                 console = TRUE)
# 
# Study: heading ~ var
# 
# LSD t Test for heading 
# P value adjustment method: bonferroni 
# 
# Mean Square Error:  21.48611 
# 
# var,  means and individual ( 95 %) CI
# 
#          heading      std  r      LCL      UCL Min Max
# Shaheen 77.91667 5.550730 12 73.65824 82.17510  67  87
# Super   93.00000 6.728501 12 88.74157 97.25843  81 101
# 
# Alpha: 0.05 ; DF Error: 3
# Critical Value of t: 3.182446 
# 
# Minimum Significant Difference: 6.022327 
# 
# Treatments with the same letter are not significantly different.
# 
#          heading groups
# Super   93.00000      a
# Shaheen 77.91667      b

For the subplot factor, use its corresponding subplot error term. Do not reuse the main-plot denominator for this comparison.

out2 <- LSD.test(y = heading, 
                 trt = age,
                 DFerror = Edf_b, 
                 MSerror = EMS_b,
                 alpha = 0.05,
                 p.adj = "bonferroni",
                 group = TRUE,
                 console = TRUE)
# 
# Study: heading ~ age
# 
# LSD t Test for heading 
# P value adjustment method: bonferroni 
# 
# Mean Square Error:  7.194444 
# 
# age,  means and individual ( 95 %) CI
# 
#    heading      std r      LCL      UCL Min Max
# 2W  78.625 7.558108 8 76.55879 80.69121  67  89
# 3W  86.625 9.117291 8 84.55879 88.69121  74  99
# 4W  91.125 9.093758 8 89.05879 93.19121  79 101
# 
# Alpha: 0.05 ; DF Error: 12
# Critical Value of t: 2.779473 
# 
# Minimum Significant Difference: 3.727616 
# 
# Treatments with the same letter are not significantly different.
# 
#    heading groups
# 4W  91.125      a
# 3W  86.625      b
# 2W  78.625      c

LSD test on interaction term

Interaction follow-ups should compare scientifically relevant simple effects or combinations using the interaction stratum and suitable multiplicity control. Avoid interpreting all pairwise combinations when the interaction was not the target of the analysis.

out3 <- LSD.test(y = heading, 
                 trt = var:age,
                 DFerror = Edf_b, 
                 MSerror = EMS_b,
                 alpha = 0.05,
                 p.adj = "bonferroni",
                 group = TRUE,
                 console = TRUE)
# 
# Study: heading ~ var:age
# 
# LSD t Test for heading 
# P value adjustment method: bonferroni 
# 
# Mean Square Error:  7.194444 
# 
# var:age,  means and individual ( 95 %) CI
# 
#            heading      std r      LCL       UCL Min Max
# Shaheen:2W   72.25 3.774917 4 69.32794  75.17206  67  75
# Shaheen:3W   78.50 3.109126 4 75.57794  81.42206  74  81
# Shaheen:4W   83.00 3.366502 4 80.07794  85.92206  79  87
# Super:2W     85.00 3.265986 4 82.07794  87.92206  81  89
# Super:3W     94.75 2.872281 4 91.82794  97.67206  93  99
# Super:4W     99.25 2.362908 4 96.32794 102.17206  96 101
# 
# Alpha: 0.05 ; DF Error: 12
# Critical Value of t: 3.648889 
# 
# Minimum Significant Difference: 6.920609 
# 
# Treatments with the same letter are not significantly different.
# 
#            heading groups
# Super:4W     99.25      a
# Super:3W     94.75      a
# Super:2W     85.00      b
# Shaheen:4W   83.00      b
# Shaheen:3W   78.50     bc
# Shaheen:2W   72.25      c

Plot variation

The package plot can summarize the spread of treatment means. Identify what the plotted “variation” measure represents; IQR, range, and variance describe spread among values and are not interchangeable with standard errors.

Check that each plot uses the intended treatment factor and response label. Factor order and units should be consistent with the ANOVA and report.

plot(out1, 
     xlab = "varieties",
     ylab = "heading (days)",
     las = 1, 
     variation = "IQR")
plot(out2, 
     xlab = "seedling age",
     ylab = "heading (days)",
     las = 1, 
     variation = "IQR")
plot(out3, 
     xlab = "var:age",
     ylab = "heading (days)",
     las = 1, 
     variation = "IQR")

Use bar.error() only after confirming the function’s definition of variation = "SE" and that the displayed SE matches the model estimand. Label error bars explicitly in the figure note.

Apply the same plotting checks to subplot means: correct factor labels, error quantity, and axis scale.

Plot bargraphs

Main effects

Add a descriptive title and axis labels with units. The figure note should state the split-plot design, the error-bar definition, and the comparison method.

Similary you can display bargraph for subplot factor by slightly changing few arguments. Use out2$means instead of out1 and also change labels for sub plot factor in names.arg argument.

To add title to this plot use title() function. In main argument type the title of the plot. You can set the value to control the size of the main title using cex.main argument. To add X and Y axis labels use xlab and ylab arguments.

# Main plot factor (varieties)
bar.err(out1$means, 
        variation = "SE", 
        ylim = c(0, 100),
        names.arg = c("Shaheen rice","Super rice"))

# Adding title, X and Y labels
title(main = "Barplot with standard error",
      cex.main = 0.8,
      xlab = "Varieties", 
      ylab = "heading (days)")

# Sub-plot factor (seedling age)
bar.err(out2$means, 
        variation = "SE", 
        ylim = c(0, 100),
        names.arg = c("2-weeks", "3-weeks", "4-weeks"))

# Adding title, X and Y labels
title(main = "Barplot with standard error",
      cex.main = 0.8,
      xlab = "Seedling age", 
      ylab = "heading (days)")

Comments

  1. How do i rearrange the x-axis? I found that if it is 25:a, 50:a, 100:a, it starts with 100:a, then 25:a, 50:a.


    ReplyDelete
    Replies
    1. You may reverse the sequence. Let me know which sequence you used first?

      Delete
  2. Hi just wondering if I can ask you some questions for my R analysis of RCBD across locations. My email address is wangtao.home@gmail.com. Could you kindly drop me an email to connect? Appreciated!!

    ReplyDelete
    Replies
    1. You can use combined analysis of variance repeated over years. Click on the link given below for more details.

      https://youtu.be/NbrsGDFE1HQ

      Delete
  3. Hey, nice info!! How are the diagnostic plots for the linear mixed-effects fit obtained?

    ReplyDelete
    Replies
    1. I have still not worked on this aspect. I shall work on it and will upload relevant content later on. Thanks for your suggestion.

      Delete

Post a Comment