1. Introduction and Research Objectives

Research Background

In an experimental study of rat growth originally discussed by Box (1950), rats were assigned to three treatment groups: a Control group receiving no additive, a Thiouracil group, and a Thyroxin group administered through their drinking water. Body weights (in grams) were measured across five occasions: Baseline (Week 0), Week 1, Week 2, Week 3, and Week 4. Following an accident, three rats were removed from the Thyroxin group, resulting in an unbalanced dataset of 27 rats and 135 total observations.

Research Objective

The objective of this analysis is to determine whether rat body weight differs significantly across treatment groups and measurement occasions, and specifically to investigate whether the trajectory of body weight changes over time depends on the treatment received (Treatment × Time interaction).


2. Data Preparation

# Load required packages
library(nlmm)
library(tidyverse)
library(rstatix)
library(ggpubr)

# Load dataset from the nlmm package
data("rats", package = "nlmm")

# Convert id, trt, and time into factors with meaningful labels
rats <- rats %>%
  mutate(
    id = factor(id),
    trt = factor(
      trt,
      levels = c(1, 2, 3),
      labels = c("Control", "Thiouracil", "Thyroxin")
    ),
    time = factor(
      time,
      levels = 0:4,
      labels = c("Week 0", "Week 1", "Week 2", "Week 3", "Week 4")
    )
  )

# Inspect structure, dimensions, first few rows, and group counts
str(rats)
## 'data.frame':    135 obs. of  4 variables:
##  $ id  : Factor w/ 27 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ...
##  $ time: Factor w/ 5 levels "Week 0","Week 1",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ trt : Factor w/ 3 levels "Control","Thiouracil",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ y   : int  57 60 52 49 56 46 51 63 49 57 ...
dim(rats)
## [1] 135   4
head(rats)
##   id   time     trt  y
## 1  1 Week 0 Control 57
## 2  2 Week 0 Control 60
## 3  3 Week 0 Control 52
## 4  4 Week 0 Control 49
## 5  5 Week 0 Control 56
## 6  6 Week 0 Control 46
table(rats$trt)
## 
##    Control Thiouracil   Thyroxin 
##         50         50         35

Experimental Design Identification

  • Dependent Variable: Body weight in grams (y, continuous/scale).
  • Between-Subjects Factor: Treatment (trt: Control, Thiouracil, Thyroxin).
  • Within-Subjects Factor: Time (time: Week 0, Week 1, Week 2, Week 3, Week 4).
  • Experimental Unit (Subject): Individual rat (id, \(N = 27\)).

Why Long Format and Subject IDs Are Necessary: The rats dataset is already structured in long format where each row represents a single observation for a given rat at a specific week, which is required by rstatix and ggplot2 to map repeated measurements properly. Including the subject identifier (id) is essential in a mixed-design ANOVA because it links repeated measurements to the same individual rat, allowing the model to partition within-subject variance from random error.


3. Descriptive Statistics and Visualization

# Compute sample size, mean, and SD for each Treatment x Time combination
summary_stats <- rats %>%
  group_by(trt, time) %>%
  get_summary_stats(y, type = "mean_sd")

knitr::kable(summary_stats, caption = "Summary Statistics of Rat Body Weight (g) by Treatment and Week")
Summary Statistics of Rat Body Weight (g) by Treatment and Week
time trt variable n mean sd
Week 0 Control y 10 54.000 5.437
Week 1 Control y 10 78.500 9.641
Week 2 Control y 10 106.000 9.922
Week 3 Control y 10 130.100 12.565
Week 4 Control y 10 160.600 15.196
Week 0 Thiouracil y 10 54.700 4.692
Week 1 Thiouracil y 10 76.300 7.917
Week 2 Thiouracil y 10 95.800 8.496
Week 3 Thiouracil y 10 108.200 9.750
Week 4 Thiouracil y 10 124.000 11.255
Week 0 Thyroxin y 7 55.571 2.992
Week 1 Thyroxin y 7 75.857 6.440
Week 2 Thyroxin y 7 104.857 11.097
Week 3 Thyroxin y 7 132.714 16.978
Week 4 Thyroxin y 7 162.857 21.505
# 1. Boxplot across measurement occasions differentiated by treatment
ggboxplot(
  rats,
  x = "time",
  y = "y",
  color = "trt",
  palette = "jco",
  xlab = "Measurement Occasion",
  ylab = "Body Weight (grams)",
  title = "Distribution of Rat Body Weight Across Weeks by Treatment"
)

# 2. Interaction plot showing mean body weight trajectories
rats %>%
  group_by(trt, time) %>%
  summarise(mean_weight = mean(y), .groups = "drop") %>%
  ggplot(aes(x = time, y = mean_weight, color = trt, group = trt)) +
  geom_line(linewidth = 1) +
  geom_point(size = 2.5) +
  labs(
    title = "Mean Body Weight Trajectories Over Time by Treatment Group",
    x = "Measurement Occasion",
    y = "Mean Body Weight (grams)",
    color = "Treatment"
  ) +
  theme_minimal()

Descriptive Observations

  • Baseline Comparison: At Week 0 (baseline), the Thyroxin group has the highest mean body weight (\(M = 55.571\text{ g}\), \(SD = 2.992\)), followed closely by Thiouracil (\(M = 54.700\text{ g}\), \(SD = 4.692\)) and Control (\(M = 54.000\text{ g}\), \(SD = 5.437\)).
  • Within-Group Change & Trajectories:Mean body weight increases steadily from Week 0 through Week 4 in all three groups. Both the Control group (from \(54.000\text{ g}\) at Week 0 to \(160.600\text{ g}\) at Week 4) and the Thyroxin group (from \(55.571\text{ g}\) at Week 0 to \(162.857\text{ g}\) at Week 4) follow steep, upward growth trajectories. In contrast, the Thiouracil group increases more gradually (from \(54.700\text{ g}\) at Week 0 to \(124.000\text{ g}\) at Week 4), showing slower growth over time.
  • Visual Interaction Assessment: Yes. In the interaction plot, all three groups start at very similar baseline weights, but the Thiouracil line diverges downward from the Control and Thyroxin lines as the weeks progress. These non-parallel, diverging trajectories visually indicate a Treatment × Time interaction.

4. Assumption Checking

A. Normality

# Shapiro-Wilk test for each Treatment x Time cell
normality_res <- rats %>%
  group_by(trt, time) %>%
  shapiro_test(y)

knitr::kable(normality_res, caption = "Shapiro-Wilk Normality Test Results")
Shapiro-Wilk Normality Test Results
time trt variable statistic p
Week 0 Control y 0.9604475 0.7909628
Week 1 Control y 0.9207427 0.3631906
Week 2 Control y 0.9775558 0.9507577
Week 3 Control y 0.9277231 0.4258738
Week 4 Control y 0.9539306 0.7150685
Week 0 Thiouracil y 0.9455834 0.6166327
Week 1 Thiouracil y 0.9714265 0.9037469
Week 2 Thiouracil y 0.9408453 0.5624572
Week 3 Thiouracil y 0.9781832 0.9547076
Week 4 Thiouracil y 0.9358011 0.5073039
Week 0 Thyroxin y 0.8879694 0.2642379
Week 1 Thyroxin y 0.7889824 0.0318177
Week 2 Thyroxin y 0.9595209 0.8146140
Week 3 Thyroxin y 0.8755771 0.2075286
Week 4 Thyroxin y 0.8603143 0.1523744
# Supplemental Q-Q plot
ggqqplot(rats, "y", ggtheme = theme_bw()) +
  facet_grid(trt ~ time)

Interpretation: Across most Treatment × Time cells, Shapiro-Wilk tests indicate no significant departure from normality (\(p > 0.05\)), with only occasional minor deviations alongside Q-Q plots that generally align closely with the reference line. Because mixed-design ANOVA is reasonably robust to minor normality deviations—especially given the small and slightly unequal group sizes (\(n = 7\) to \(10\))—the normality assumption is considered adequately met.

B. Outliers

# Identify statistical outliers and extreme outliers
outliers_res <- rats %>%
  group_by(trt, time) %>%
  identify_outliers(y)

outliers_res
## # A tibble: 2 × 6
##   time   trt        id        y is.outlier is.extreme
##   <fct>  <fct>      <fct> <int> <lgl>      <lgl>     
## 1 Week 1 Thiouracil 19       61 TRUE       FALSE     
## 2 Week 2 Thiouracil 19       78 TRUE       FALSE

Interpretation: Examination of outliers_res shows no extreme outliers (is.extreme == TRUE is absent), with any flagged points being only mild outliers (is.outlier == TRUE). Because these mild deviations reflect natural biological variation in rat growth and removing observations would further reduce an already modest and unbalanced sample (\(N = 27\)), all data points are retained.

C. Homogeneity of Variances

# Levene's test at each measurement occasion
levene_res <- rats %>%
  group_by(time) %>%
  levene_test(y ~ trt)

knitr::kable(levene_res, caption = "Levene's Test for Homogeneity of Variances")
Levene’s Test for Homogeneity of Variances
time df1 df2 statistic p
Week 0 2 24 2.0593812 0.1494791
Week 1 2 24 1.1759702 0.3256745
Week 2 2 24 0.4045716 0.6717284
Week 3 2 24 1.6664135 0.2100488
Week 4 2 24 2.2798813 0.1240166

Interpretation: Levene’s test at each measurement occasion yields \(p > 0.05\), indicating that error variances are homogeneous across treatment groups at each week.

D. Homogeneity of Covariance Matrices

# Pivot data to wide format (one row per rat) for Box's M test
rats_wide <- rats %>%
  pivot_wider(
    id_cols = c(id, trt),
    names_from = time,
    values_from = y,
    names_prefix = "time_"
  )

box_m(
  rats_wide %>% select(starts_with("time_")),
  rats_wide$trt
)
## # A tibble: 1 × 4
##   statistic p.value parameter method                                            
##       <dbl>   <dbl>     <dbl> <chr>                                             
## 1      22.4   0.839        30 Box's M-test for Homogeneity of Covariance Matric…

Interpretation: Evaluating Box’s M test at the recommended significance threshold of \(\alpha = 0.001\) shows \(p > 0.001\), indicating that the homogeneity of covariance matrices assumption is satisfied across treatment groups.


5. Mixed-Design Repeated Measures ANOVA

# Conduct two-way mixed-design repeated measures ANOVA
res.aov <- anova_test(
  data = rats,
  dv = y,
  wid = id,
  between = trt,
  within = time
)

# Display full output including Mauchly's Test of Sphericity and Greenhouse-Geisser corrections
res.aov
## ANOVA Table (type III tests)
## 
## $ANOVA
##     Effect DFn DFd       F        p p<.05   ges
## 1      trt   2  24   7.884 2.00e-03     * 0.307
## 2     time   4  96 745.920 2.38e-71     * 0.910
## 3 trt:time   8  96  16.586 3.42e-15     * 0.310
## 
## $`Mauchly's Test for Sphericity`
##     Effect     W        p p<.05
## 1     time 0.011 1.41e-17     *
## 2 trt:time 0.011 1.41e-17     *
## 
## $`Sphericity Corrections`
##     Effect   GGe      DF[GG]    p[GG] p[GG]<.05   HFe      DF[HF]    p[HF]
## 1     time 0.342 1.37, 32.82 6.00e-26         * 0.356 1.42, 34.13 6.80e-27
## 2 trt:time 0.342 2.73, 32.82 1.73e-06         * 0.356 2.84, 34.13 1.13e-06
##   p[HF]<.05
## 1         *
## 2         *
# Display formatted ANOVA table
get_anova_table(res.aov)
## ANOVA Table (type III tests)
## 
##     Effect  DFn   DFd       F        p p<.05   ges
## 1      trt 2.00 24.00   7.884 2.00e-03     * 0.307
## 2     time 1.37 32.82 745.920 6.00e-26     * 0.910
## 3 trt:time 2.73 32.82  16.586 1.73e-06     * 0.310

Evaluation of Sphericity and Main/Interaction Effects

  • E. Sphericity: Mauchly’s test of sphericity is statistically significant for both time (\(W = 0.011, p = 1.41 \times 10^{-17}\)) and trt:time (\(W = 0.011, p = 1.41 \times 10^{-17}\)). Because \(p < 0.05\), the assumption of sphericity is violated, so Greenhouse–Geisser corrected degrees of freedom and \(p\)-values are applied (\(\varepsilon = 0.342\)): \(\text{df} = (1.37, 32.82), p = 6.00 \times 10^{-26}\) for time and \(\text{df} = (2.73, 32.82), p = 1.73 \times 10^{-6}\) for trt:time.
  • A. Main Effect of Treatment (trt): \(F(2, 24) = 7.884, p = 0.002, \eta^2_G = 0.307\). There is a statistically significant main effect of treatment on rat body weight averaged across measurement occasions (\(p < 0.05\)).
  • B. Main Effect of Time (time): \(F(1.37, 32.82) = 745.920, p = 6.00 \times 10^{-26}\ (p < .001), \eta^2_G = 0.910\). There is a statistically significant main effect of time, showing that rat body weight changes substantially across the five weekly measurement occasions (\(p < 0.05\)).
  • C. Treatment × Time Interaction (trt:time): \(F(2.73, 32.82) = 16.586, p = 1.73 \times 10^{-6}\ (p < .001), \eta^2_G = 0.310\). The interaction is statistically significant (\(p < 0.05\)), indicating that rat growth trajectories over time depend significantly on the treatment group.

6. Post Hoc Analysis and Interaction Decomposition

Because the Treatment × Time interaction is statistically significant, simple main effects are examined below.

A. Treatment Differences at Each Measurement Occasion

# One-way ANOVA comparing treatments at each week
one_way_trt <- rats %>%
  group_by(time) %>%
  anova_test(dv = y, wid = id, between = trt) %>%
  get_anova_table()

knitr::kable(one_way_trt, caption = "Simple Main Effect of Treatment at Each Week")
Simple Main Effect of Treatment at Each Week
time Effect DFn DFd F p p<.05 ges
Week 0 trt 2 24 0.236 7.92e-01 0.019
Week 1 trt 2 24 0.266 7.69e-01 0.022
Week 2 trt 2 24 3.173 6.00e-02 0.209
Week 3 trt 2 24 10.041 6.78e-04 * 0.456
Week 4 trt 2 24 17.798 1.82e-05 * 0.597
# Pairwise comparisons using Tukey's HSD
tukey_trt <- rats %>%
  group_by(time) %>%
  tukey_hsd(y ~ trt)

knitr::kable(tukey_trt, caption = "Tukey's HSD Pairwise Comparisons by Week")
Tukey’s HSD Pairwise Comparisons by Week
time term group1 group2 null.value estimate conf.low conf.high p.adj p.adj.signif
Week 0 trt Control Thiouracil 0 0.7000000 -4.487581 5.8875807 0.9394817 ns
Week 0 trt Control Thyroxin 0 1.5714286 -4.145007 7.2878641 0.7735318 ns
Week 0 trt Thiouracil Thyroxin 0 0.8714286 -4.845007 6.5878641 0.9234749 ns
Week 1 trt Control Thiouracil 0 -2.2000000 -11.458665 7.0586650 0.8249543 ns
Week 1 trt Control Thyroxin 0 -2.6428571 -12.845409 7.5596948 0.7958740 ns
Week 1 trt Thiouracil Thyroxin 0 -0.4428571 -10.645409 9.7596948 0.9935446 ns
Week 2 trt Control Thiouracil 0 -10.2000000 -21.072183 0.6721825 0.0688373 ns
Week 2 trt Control Thyroxin 0 -1.1428571 -13.123419 10.8377044 0.9692398 ns
Week 2 trt Thiouracil Thyroxin 0 9.0571429 -2.923419 21.0377044 0.1639000 ns
Week 3 trt Control Thiouracil 0 -21.9000000 -36.328775 -7.4712252 0.0024809 **
Week 3 trt Control Thyroxin 0 2.6142857 -13.285450 18.5140211 0.9115928 ns
Week 3 trt Thiouracil Thyroxin 0 24.5142857 8.614550 40.4140211 0.0021393 **
Week 4 trt Control Thiouracil 0 -36.6000000 -54.248561 -18.9514386 0.0000761 ****
Week 4 trt Control Thyroxin 0 2.2571429 -17.190625 21.7049103 0.9548342 ns
Week 4 trt Thiouracil Thyroxin 0 38.8571429 19.409375 58.3049103 0.0001225 ***

Summary: Simple main effects of treatment show no statistically significant differences in body weight among the three groups at Week 0 (\(p = .792\)), Week 1 (\(p = .769\)), or Week 2 (\(p = .060\), marginally non-significant at \(\alpha = .05\)). Statistically significant differences between treatment groups emerge at Week 3 (\(p < .001\)) and persist through Week 4 (\(p < .001\)). Tukey’s HSD post hoc comparisons indicate that at Weeks 3 and 4, rats in the Thiouracil group weigh significantly less than both the Control group (\(p = .002\) at Week 3; \(p < .001\) at Week 4) and the Thyroxin group (\(p = .002\) at Week 3; \(p < .001\) at Week 4), whereas there is no significant difference between the Control and Thyroxin groups at any measurement occasion (\(p > .05\)).

B. Changes Over Time Within Each Treatment Group

# Repeated measures ANOVA across time within each treatment group
one_way_time <- rats %>%
  group_by(trt) %>%
  anova_test(dv = y, wid = id, within = time) %>%
  get_anova_table()

knitr::kable(one_way_time, caption = "Simple Main Effect of Time Within Each Treatment")
Simple Main Effect of Time Within Each Treatment
trt Effect DFn DFd F p p<.05 ges
Control time 1.32 11.90 398.811 0.0e+00 * 0.928
Thiouracil time 1.77 15.90 225.074 0.0e+00 * 0.896
Thyroxin time 1.15 6.91 160.945 3.8e-06 * 0.903
# Paired pairwise comparisons using Holm-adjusted p-values
pwc_time <- rats %>%
  group_by(trt) %>%
  pairwise_t_test(
    y ~ time,
    paired = TRUE,
    p.adjust.method = "holm"
  )

knitr::kable(pwc_time, caption = "Holm-Adjusted Pairwise Comparisons Across Weeks")
Holm-Adjusted Pairwise Comparisons Across Weeks
trt .y. group1 group2 n1 n2 statistic df p p.adj p.adj.signif
Control y Week 0 Week 1 10 10 -16.019955 9 0.0000001 0.0000002 ****
Control y Week 0 Week 2 10 10 -23.517885 9 0.0000000 0.0000000 ****
Control y Week 0 Week 3 10 10 -20.973218 9 0.0000000 0.0000000 ****
Control y Week 0 Week 4 10 10 -23.371099 9 0.0000000 0.0000000 ****
Control y Week 1 Week 2 10 10 -18.333333 9 0.0000000 0.0000001 ****
Control y Week 1 Week 3 10 10 -15.779497 9 0.0000001 0.0000002 ****
Control y Week 1 Week 4 10 10 -19.020014 9 0.0000000 0.0000001 ****
Control y Week 2 Week 3 10 10 -12.966654 9 0.0000004 0.0000004 ****
Control y Week 2 Week 4 10 10 -18.263242 9 0.0000000 0.0000001 ****
Control y Week 3 Week 4 10 10 -17.996615 9 0.0000000 0.0000001 ****
Thiouracil y Week 0 Week 1 10 10 -12.698561 9 0.0000005 0.0000028 ****
Thiouracil y Week 0 Week 2 10 10 -22.042472 9 0.0000000 0.0000000 ****
Thiouracil y Week 0 Week 3 10 10 -21.790900 9 0.0000000 0.0000000 ****
Thiouracil y Week 0 Week 4 10 10 -20.116320 9 0.0000000 0.0000001 ****
Thiouracil y Week 1 Week 2 10 10 -14.602202 9 0.0000001 0.0000010 ****
Thiouracil y Week 1 Week 3 10 10 -11.935489 9 0.0000008 0.0000033 ****
Thiouracil y Week 1 Week 4 10 10 -12.225412 9 0.0000007 0.0000033 ****
Thiouracil y Week 2 Week 3 10 10 -7.262080 9 0.0000475 0.0000896 ****
Thiouracil y Week 2 Week 4 10 10 -9.254888 9 0.0000068 0.0000204 ****
Thiouracil y Week 3 Week 4 10 10 -7.317464 9 0.0000448 0.0000896 ****
Thyroxin y Week 0 Week 1 7 7 -12.454224 6 0.0000164 0.0000982 ****
Thyroxin y Week 0 Week 2 7 7 -13.961015 6 0.0000084 0.0000736 ****
Thyroxin y Week 0 Week 3 7 7 -13.107208 6 0.0000122 0.0000852 ****
Thyroxin y Week 0 Week 4 7 7 -14.031461 6 0.0000082 0.0000736 ****
Thyroxin y Week 1 Week 2 7 7 -11.982711 6 0.0000205 0.0000982 ****
Thyroxin y Week 1 Week 3 7 7 -10.938029 6 0.0000347 0.0000982 ****
Thyroxin y Week 1 Week 4 7 7 -12.434615 6 0.0000165 0.0000982 ****
Thyroxin y Week 2 Week 3 7 7 -8.559550 6 0.0001396 0.0001396 ***
Thyroxin y Week 2 Week 4 7 7 -11.588968 6 0.0000248 0.0000982 ****
Thyroxin y Week 3 Week 4 7 7 -14.772955 6 0.0000060 0.0000605 ****

Summary: Repeated measures ANOVAs within each treatment group confirm that body weight changes significantly across measurement occasions in the Control, Thiouracil, and Thyroxin groups (\(p < .001\)). Holm-adjusted paired comparisons show consistent increases in body weight across time in all three groups, with rats gaining weight as the study progresses from baseline (Week 0) through Week 4. However, the magnitude of weight gain over successive weeks is noticeably smaller in the Thiouracil group than in the Control and Thyroxin groups.

C. Interpretation of Decomposition

Decomposing the Treatment × Time interaction clarifies both when and where the growth trajectories diverge across the four-week study. All three groups start at comparable baseline body weights and follow similar early trajectories through Week 1, meaning early differences are minimal. Beginning around Week 2, however, the Thiouracil group’s growth curve flattens relative to the Control and Thyroxin groups, producing a widening gap through Weeks 3 and 4. Because Control and Thyroxin rats maintain comparable growth trajectories across all time points while Thiouracil rats exhibit stunted weight gain from Week 2 onward, the interaction is driven specifically by Thiouracil’s growth-suppressing effect over time rather than differences between Control and Thyroxin.


7. Discussion and Conclusion

APA-Style Results and Interpretation

A two-way mixed-design repeated measures ANOVA was conducted to examine the effects of treatment (Control, Thiouracil, Thyroxin) and time (Weeks 0–4) on rat body weight (\(N = 27\)). There was a statistically significant main effect of treatment, \(F(2, 24) = 7.884, p = .002, \eta^2_G = 0.307\), and a statistically significant main effect of time (Greenhouse–Geisser corrected), \(F(1.37, 32.82) = 745.920, p < .001, \eta^2_G = 0.910\). Crucially, these main effects were qualified by a statistically significant Treatment × Time interaction (Greenhouse–Geisser corrected), \(F(2.73, 32.82) = 16.586, p < .001, \eta^2_G = 0.310\). Post hoc simple main effects analyses revealed that while treatment groups did not differ significantly from Week 0 through Week 2 (\(p > .05\)), statistically significant divergence emerged by Week 3 and persisted through Week 4 (\(p < .001\)), where rats treated with Thiouracil exhibited significantly lower body weights compared to both the Control and Thyroxin groups (\(p < .01\)). Biologically, Thiouracil acts as an antithyroid agent that suppresses thyroid hormone synthesis and slows metabolic growth rate in rats, whereas Thyroxin maintains growth rates comparable to untreated controls. Because this experiment was conducted solely on laboratory rats, these findings should not be generalized directly to human health.

Conclusion

In answer to the central research question, yes—the effect of treatment on rat body weight depends significantly on the measurement occasion. While all groups begin at comparable baseline weights, growth trajectories diverge over the four-week period due to the growth-suppressing effect of Thiouracil relative to Control and Thyroxin treatments.


8. References

• Box, G. E. P. (1950). Problems in the analysis of growth and wear curves. Biometrics, 6(4), 362–389.

• Datanovia. (2026). Mixed ANOVA in R: One Between- and One Within-Subjects Factor. datanovia.com

• Geraci, M. (2023). nlmm: Generalized Laplace Mixed-Effects Models (Dataset: rats). rdrr.io