Shaw and Shackleton (2010) studied the effects of four factors (insect supplementation, water treatment, site and rosette size) on growth and seed set of a biennial herb, the teasel (Dipacus fullonum) near London. The design was fully balanced with three plants per factor combination. Preliminary analyses of both response variables (using residual plots) suggested a need transformation. In both cases, small predicted values were associated with small spreads of residuals. For seed set, variance of the residuals increased steadily with predicted values (Figure 7.8), whereas residuals for biomass showed a pattern of strongly increasing, then decreasing spread of the residuals. In both cases, log-transformation of the response variable removed the issues with the distribution of residuals.

Blokenearexeter, CC0, via Wikimedia Commons

Blokenearexeter, CC0, via Wikimedia Commons

Shaw, P. J. A. & Shackleton, K. (2010). Carnivory in the teasel Dipsacus fullonum—the effect of experimental feeding on growth and seed set. PLoS One, 6, e17935.

The paper is here.

Preliminaries

First, load the required packages (car, sjstats) + ggplot2, patchwork, emmeans

Import shawshack data file (shawshack.csv)

shawshack <- read.csv("../data/shawshack.csv")
head(shawshack,10)

Convert predictors to factors

shawshack$site <- factor(shawshack$site)
shawshack$sizeclass <- factor(shawshack$sizeclass)
shawshack$maggot <- factor(shawshack$maggot)
shawshack$water <- factor(shawshack$water)

Fit model to untransformed seedmass and check residuals

shawshack1.aov <- aov(seedmass~site*sizeclass*maggot*water, data=shawshack)
plot(shawshack1.aov)

Fit model to untransformed biomass and check residuals

shawshack2.aov <- aov(biomass~site*sizeclass*maggot*water, data=shawshack)
plot(shawshack2.aov)

Residuals show patterns

Analyse log transformed data for both

Fit models and check residuals first

shawshack3.aov <- aov(log10(seedmass)~site*sizeclass*maggot*water, data=shawshack)
plot(shawshack3.aov)

shawshack4.aov <- aov(log10(biomass)~site*sizeclass*maggot*water, data=shawshack)
plot(shawshack4.aov)

Get model results

Tests, then effect sizes

Seed mass

summary(shawshack3.aov)
                            Df Sum Sq Mean Sq F value  Pr(>F)    
site                         1   8.60    8.60   56.64 1.2e-09 ***
sizeclass                    1   2.56    2.56   16.89 0.00015 ***
maggot                       2   1.00    0.50    3.31 0.04512 *  
water                        1   0.00    0.00    0.02 0.90011    
site:sizeclass               1   0.01    0.01    0.08 0.77359    
site:maggot                  2   0.76    0.38    2.49 0.09372 .  
sizeclass:maggot             2   0.25    0.13    0.84 0.44004    
site:water                   1   0.00    0.00    0.02 0.89538    
sizeclass:water              1   0.67    0.67    4.39 0.04134 *  
maggot:water                 2   0.05    0.03    0.18 0.83571    
site:sizeclass:maggot        2   0.20    0.10    0.66 0.51926    
site:sizeclass:water         1   0.15    0.15    1.00 0.32226    
site:maggot:water            2   0.15    0.07    0.49 0.61625    
sizeclass:maggot:water       2   1.02    0.51    3.35 0.04361 *  
site:sizeclass:maggot:water  2   0.08    0.04    0.26 0.77302    
Residuals                   48   7.29    0.15                    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
anova_stats(shawshack3.aov)
term                        | df | sumsq | meansq | statistic | p.value | etasq | partial.etasq | omegasq | partial.omegasq | epsilonsq | cohens.f | power
----------------------------------------------------------------------------------------------------------------------------------------------------------
site                        |  1 | 8.597 |  8.597 |    56.640 |  < .001 | 0.377 |         0.541 |   0.368 |           0.436 |     0.371 |    1.086 | 1.000
sizeclass                   |  1 | 2.563 |  2.563 |    16.885 |  < .001 | 0.112 |         0.260 |   0.105 |           0.181 |     0.106 |    0.593 | 0.984
maggot                      |  2 | 1.004 |  0.502 |     3.307 |   0.045 | 0.044 |         0.121 |   0.031 |           0.060 |     0.031 |    0.371 | 0.628
water                       |  1 | 0.002 |  0.002 |     0.016 |   0.900 | 0.000 |         0.000 |  -0.007 |          -0.014 |    -0.007 |    0.018 | 0.052
site:sizeclass              |  1 | 0.013 |  0.013 |     0.084 |   0.774 | 0.001 |         0.002 |  -0.006 |          -0.013 |    -0.006 |    0.042 | 0.060
site:maggot                 |  2 | 0.755 |  0.378 |     2.488 |   0.094 | 0.033 |         0.094 |   0.020 |           0.040 |     0.020 |    0.322 | 0.501
sizeclass:maggot            |  2 | 0.254 |  0.127 |     0.835 |   0.440 | 0.011 |         0.034 |  -0.002 |          -0.005 |    -0.002 |    0.187 | 0.194
site:water                  |  1 | 0.003 |  0.003 |     0.017 |   0.895 | 0.000 |         0.000 |  -0.006 |          -0.014 |    -0.007 |    0.019 | 0.052
sizeclass:water             |  1 | 0.667 |  0.667 |     4.395 |   0.041 | 0.029 |         0.084 |   0.022 |           0.045 |     0.023 |    0.303 | 0.554
maggot:water                |  2 | 0.055 |  0.027 |     0.180 |   0.836 | 0.002 |         0.007 |  -0.011 |          -0.023 |    -0.011 |    0.087 | 0.078
site:sizeclass:maggot       |  2 | 0.202 |  0.101 |     0.664 |   0.519 | 0.009 |         0.027 |  -0.004 |          -0.009 |    -0.004 |    0.166 | 0.162
site:sizeclass:water        |  1 | 0.152 |  0.152 |     1.000 |   0.322 | 0.007 |         0.020 |   0.000 |           0.000 |     0.000 |    0.144 | 0.170
site:maggot:water           |  2 | 0.148 |  0.074 |     0.489 |   0.616 | 0.007 |         0.020 |  -0.007 |          -0.014 |    -0.007 |    0.143 | 0.131
sizeclass:maggot:water      |  2 | 1.016 |  0.508 |     3.346 |   0.044 | 0.045 |         0.122 |   0.031 |           0.061 |     0.031 |    0.373 | 0.633
site:sizeclass:maggot:water |  2 | 0.079 |  0.039 |     0.259 |   0.773 | 0.003 |         0.011 |  -0.010 |          -0.021 |    -0.010 |    0.104 | 0.091
Residuals                   | 48 | 7.286 |  0.152 |           |         |       |               |         |                 |           |          |      

Now biomass

summary(shawshack4.aov)
                            Df Sum Sq Mean Sq F value  Pr(>F)    
site                         1  10.30   10.30  278.75 < 2e-16 ***
sizeclass                    1   2.82    2.82   76.30 1.7e-11 ***
maggot                       2   0.09    0.05    1.28   0.287    
water                        1   0.03    0.03    0.77   0.385    
site:sizeclass               1   0.02    0.02    0.59   0.445    
site:maggot                  2   0.15    0.07    1.96   0.151    
sizeclass:maggot             2   0.08    0.04    1.11   0.338    
site:water                   1   0.01    0.01    0.24   0.629    
sizeclass:water              1   0.25    0.25    6.81   0.012 *  
maggot:water                 2   0.07    0.03    0.94   0.399    
site:sizeclass:maggot        2   0.14    0.07    1.96   0.152    
site:sizeclass:water         1   0.00    0.00    0.02   0.903    
site:maggot:water            2   0.05    0.02    0.61   0.547    
sizeclass:maggot:water       2   0.07    0.04    0.98   0.382    
site:sizeclass:maggot:water  2   0.02    0.01    0.26   0.775    
Residuals                   48   1.77    0.04                    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
anova_stats(shawshack4.aov)
term                        | df |  sumsq | meansq | statistic | p.value | etasq | partial.etasq | omegasq | partial.omegasq | epsilonsq | cohens.f | power
-----------------------------------------------------------------------------------------------------------------------------------------------------------
site                        |  1 | 10.300 | 10.300 |   278.747 |  < .001 | 0.649 |         0.853 |   0.645 |           0.794 |     0.646 |    2.410 | 1.000
sizeclass                   |  1 |  2.819 |  2.819 |    76.299 |  < .001 | 0.178 |         0.614 |   0.175 |           0.511 |     0.175 |    1.261 | 1.000
maggot                      |  2 |  0.095 |  0.047 |     1.283 |   0.287 | 0.006 |         0.051 |   0.001 |           0.008 |     0.001 |    0.231 | 0.279
water                       |  1 |  0.028 |  0.028 |     0.769 |   0.385 | 0.002 |         0.016 |  -0.001 |          -0.003 |    -0.001 |    0.127 | 0.142
site:sizeclass              |  1 |  0.022 |  0.022 |     0.594 |   0.445 | 0.001 |         0.012 |  -0.001 |          -0.006 |    -0.001 |    0.111 | 0.120
site:maggot                 |  2 |  0.145 |  0.073 |     1.964 |   0.151 | 0.009 |         0.076 |   0.004 |           0.026 |     0.004 |    0.286 | 0.408
sizeclass:maggot            |  2 |  0.082 |  0.041 |     1.109 |   0.338 | 0.005 |         0.044 |   0.001 |           0.003 |     0.001 |    0.215 | 0.246
site:water                  |  1 |  0.009 |  0.009 |     0.236 |   0.629 | 0.001 |         0.005 |  -0.002 |          -0.011 |    -0.002 |    0.070 | 0.077
sizeclass:water             |  1 |  0.252 |  0.252 |     6.813 |   0.012 | 0.016 |         0.124 |   0.013 |           0.075 |     0.014 |    0.377 | 0.742
maggot:water                |  2 |  0.069 |  0.035 |     0.936 |   0.399 | 0.004 |         0.038 |   0.000 |          -0.002 |     0.000 |    0.197 | 0.213
site:sizeclass:maggot       |  2 |  0.145 |  0.072 |     1.959 |   0.152 | 0.009 |         0.075 |   0.004 |           0.026 |     0.004 |    0.286 | 0.407
site:sizeclass:water        |  1 |  0.001 |  0.001 |     0.015 |   0.903 | 0.000 |         0.000 |  -0.002 |          -0.014 |    -0.002 |    0.018 | 0.052
site:maggot:water           |  2 |  0.045 |  0.023 |     0.610 |   0.547 | 0.003 |         0.025 |  -0.002 |          -0.011 |    -0.002 |    0.159 | 0.152
sizeclass:maggot:water      |  2 |  0.073 |  0.036 |     0.983 |   0.382 | 0.005 |         0.039 |   0.000 |           0.000 |     0.000 |    0.202 | 0.222
site:sizeclass:maggot:water |  2 |  0.019 |  0.009 |     0.256 |   0.775 | 0.001 |         0.011 |  -0.003 |          -0.021 |    -0.003 |    0.103 | 0.090
Residuals                   | 48 |  1.774 |  0.037 |           |         |       |               |         |                 |           |          |      

Figures

The first figure, 7.7 in the book, is a panel of 4 residual plots, 2 dependent variables, raw and transformed

p1<-ggplot(shawshack1.aov, aes(x = shawshack1.aov$fitted.values, y = shawshack1.aov$residuals)) +
  geom_point(color=sc, alpha=0.5) +
  theme_classic(base_size = 10)+
  theme(
    axis.text = element_blank(),
    axis.line = element_line(color = ac),
    axis.ticks = element_blank(),
    plot.title = element_text(hjust=0.5, size=8)
        )+labs(x = NULL, y = NULL, title="Seeds, Raw"
       )
p2<-ggplot(shawshack2.aov, aes(x = shawshack2.aov$fitted.values, y = shawshack2.aov$residuals)) +
  geom_point(color=sc, alpha=0.5) +
  theme_classic(base_size = 10)+
  theme(
    axis.text = element_blank(),
    axis.line = element_line(color = ac),
    axis.ticks = element_blank(),
    plot.title = element_text(hjust=0.5, size=8)
        )+labs(x = NULL, y = NULL, title="Growth, Raw"
       )
p3<-ggplot(shawshack1.aov, aes(x = shawshack3.aov$fitted.values, y = shawshack3.aov$residuals)) +
  geom_point(color=sc, alpha=0.5) +
  theme_classic(base_size = 10)+
  theme(
    axis.text = element_blank(),
    axis.line = element_line(color = ac),
    axis.ticks = element_blank(),
    plot.title = element_text(hjust=0.5, size=8)
        )+labs(x = NULL, y = NULL, title="Seeds, Log-transformed"
       )
p4<-ggplot(shawshack1.aov, aes(x = shawshack4.aov$fitted.values, y = shawshack4.aov$residuals)) +
  geom_point(color=sc, alpha=.5) +
  theme_classic(base_size = 10)+
  theme(
    axis.text = element_blank(),
    axis.line = element_line(color = ac),
    axis.ticks = element_blank(),
    plot.title = element_text(hjust=0.5, size=8)
        )+labs(x = NULL, y = NULL, title="Growth, Log-transformed"
       )
p1+p2+p3+p4

The second figure, 7.8 in the book, shows the effects that were detected. For seed number, there was a three-way interaction between plant size, insects, and water. We’ll show that as two panels, each showing the relationship between water and insects, with one for large and one for small plants. There was a separate effect of site, which we show as a simple bar graph. For growth, we detected an interaction between size and water, plus an independent main effect of site. We’ll show the size x water interaction, pooling across the other factors.

LS0tCnRpdGxlOiAiUUsgQm94IDcuNiIKCm91dHB1dDogCiAgaHRtbF9ub3RlYm9vazoKICAgIHRoZW1lOiBmbGF0bHkKLS0tCgpgYGB7ciBzZXR1cCwgaW5jbHVkZT1GQUxTRX0Ka25pdHI6Om9wdHNfY2h1bmskc2V0KGVjaG8gPSBUUlVFKQpgYGAKClNoYXcgYW5kIFNoYWNrbGV0b24gKDIwMTApIHN0dWRpZWQgdGhlIGVmZmVjdHMgb2YgZm91ciBmYWN0b3JzIChpbnNlY3Qgc3VwcGxlbWVudGF0aW9uLCB3YXRlciB0cmVhdG1lbnQsIHNpdGUgYW5kIHJvc2V0dGUgc2l6ZSkgb24gZ3Jvd3RoIGFuZCBzZWVkIHNldCBvZiBhIGJpZW5uaWFsIGhlcmIsIHRoZSB0ZWFzZWwgKCpEaXBhY3VzIGZ1bGxvbnVtKikgbmVhciBMb25kb24uIFRoZSBkZXNpZ24gd2F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