Skip to contents

Model: y_ij = mu + tau_i (treatment) + beta_j (block) + eps_ij Returns Type-I ANOVA: block enters first, then treatment.

Usage

mrm_rcbd(data, response_col, treatment_col, block_col)

Arguments

data

data.frame.

response_col, treatment_col, block_col

Column names.

Value

Named list with anova (data.frame), n, n_treatments, n_blocks, interpretation.

Examples

set.seed(2026)
df <- expand.grid(
  treatment = c("A", "B", "C"),
  block = c("B1", "B2", "B3", "B4")
)
# Treatment effect + block effect + noise
df$y <- as.numeric(df$treatment) * 2 +
  as.numeric(df$block) * 0.5 + rnorm(nrow(df), 0, 0.3)
res <- mrm_rcbd(df,
  response_col = "y",
  treatment_col = "treatment", block_col = "block"
)
res$anova
#>   Df    Sum Sq     Mean Sq   F value       Pr(>F)    source
#> 1  3  3.580259  1.19341977  17.75865 2.180709e-03     block
#> 2  2 29.415727 14.70786371 218.85995 2.472447e-06 treatment
#> 3  6  0.403213  0.06720217        NA           NA Residuals