library(ggplot2) # for general plotting
library(car)     # for ANOVA (Type II used, better than Type I when there is an unbalanced design)

Information of data source

Damage from TU and TU-A (100 mites) on multiple tomato cultivars, 24hpi.

Read in the data and view structure to identify any issues in data formatting

damage.data <- read.csv("~/Lab Stuff/Adapted mites/Tomato/Damage assay/Adapted vs. Non-adapted on multiple cultivars/Damage R data.csv", header = TRUE)

# Trial as a factor
damage.data$Trial <- factor(damage.data$Trial)

str(damage.data)
## 'data.frame':    144 obs. of  4 variables:
##  $ Trial         : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 1 1 1 1 1 ...
##  $ Mite.Strain   : Factor w/ 2 levels "TU","TU-A": 1 1 1 1 1 1 1 1 1 1 ...
##  $ Plant.Genotype: Factor w/ 4 levels "Castlemart","Heinz",..: 1 1 1 1 1 1 2 2 2 2 ...
##  $ Damage        : num  1.875 0.812 2 1.062 1 ...

Formulate hypothesis

H0: There will be no difference in damage produced by the mite strains and no difference in damage between tomato cultivars.

HA: TU-A will produce more damage on all tomato cultivars compared to TU mites.

Conduct data exploration

Outliers in the response variable (Damage) within the explanatory variables (Trial, Mite, Plant.Genotype).

ggplot(damage.data, aes(x = Trial, y = Damage)) + geom_boxplot() + theme_classic()

ggplot(damage.data, aes(x = Mite.Strain, y = Damage)) + geom_boxplot() + theme_classic()

ggplot(damage.data, aes(x = Plant.Genotype, y = Damage)) + geom_boxplot() + theme_classic()

A few outliers, they seem fairly well distributed among trials and mite strains. In the interests of keeping the sample size high and balanced, I will include them unless they cause trouble during model validation.

Collinearity of the explanatory variables

Des not apply, all explanatory variables are categorical/factorial.

Spatial/temporal or other hierarchical aspects of sampling design

No, I am treating Trial as a main effect to check for reproducibility (not a random effect/blocking factor).

Interactions (is the quality of the data good enough to include them?)

Interaction betweenTrial and Mite.Strain will be performed to test for reproducibility.

Interaction betweenTrial and Plant.Genotype will be performed to test for reproducibility.

Interaction between Mite.Strain and Plant.Genotype to test if mite strains are performing the same on each tomato cultivar.

Zero inflation in Y

No

Are categorical covariates balanced?

summary(damage.data)
##  Trial  Mite.Strain    Plant.Genotype     Damage        
##  1:48   TU  :72     Castlemart:36     Min.   :  0.0625  
##  2:48   TU-A:72     Heinz     :36     1st Qu.:  0.7969  
##  3:48               Microtom  :36     Median :  4.8438  
##                     Moneymaker:36     Mean   : 21.0877  
##                                       3rd Qu.: 34.5469  
##                                       Max.   :130.3750

Yes

Apply model

# fit linear model and display model fit information and ANOVA table
# full model including 3 way interaction term - to verify it is not significant, if it is, interpretation of hypothesis testing will be problematic
m.0 <- lm(Damage ~ Mite.Strain + Plant.Genotype + Trial + Mite.Strain:Plant.Genotype + Mite.Strain:Trial + Plant.Genotype:Trial + Mite.Strain:Plant.Genotype:Trial, data = damage.data)
summary(m.0)
## 
## Call:
## lm(formula = Damage ~ Mite.Strain + Plant.Genotype + Trial + 
##     Mite.Strain:Plant.Genotype + Mite.Strain:Trial + Plant.Genotype:Trial + 
##     Mite.Strain:Plant.Genotype:Trial, data = damage.data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -63.021  -1.727  -0.089   1.089  38.229 
## 
## Coefficients:
##                                                  Estimate Std. Error
## (Intercept)                                       1.17708    5.48150
## Mite.StrainTU-A                                  47.72917    7.75201
## Plant.GenotypeHeinz                               0.32292    7.75201
## Plant.GenotypeMicrotom                           -0.78125    7.75201
## Plant.GenotypeMoneymaker                          0.65625    7.75201
## Trial2                                            0.10417    7.75201
## Trial3                                           -0.26042    7.75201
## Mite.StrainTU-A:Plant.GenotypeHeinz              14.89583   10.96300
## Mite.StrainTU-A:Plant.GenotypeMicrotom           -6.94792   10.96300
## Mite.StrainTU-A:Plant.GenotypeMoneymaker         42.58333   10.96300
## Mite.StrainTU-A:Trial2                          -29.33333   10.96300
## Mite.StrainTU-A:Trial3                          -17.51042   10.96300
## Plant.GenotypeHeinz:Trial2                       -0.35417   10.96300
## Plant.GenotypeMicrotom:Trial2                    -0.09375   10.96300
## Plant.GenotypeMoneymaker:Trial2                  -1.11458   10.96300
## Plant.GenotypeHeinz:Trial3                        0.72917   10.96300
## Plant.GenotypeMicrotom:Trial3                     0.13542   10.96300
## Plant.GenotypeMoneymaker:Trial3                  -0.62500   10.96300
## Mite.StrainTU-A:Plant.GenotypeHeinz:Trial2      -16.61458   15.50403
## Mite.StrainTU-A:Plant.GenotypeMicrotom:Trial2    16.70833   15.50403
## Mite.StrainTU-A:Plant.GenotypeMoneymaker:Trial2 -20.83333   15.50403
## Mite.StrainTU-A:Plant.GenotypeHeinz:Trial3       -7.86458   15.50403
## Mite.StrainTU-A:Plant.GenotypeMicrotom:Trial3    -7.16667   15.50403
## Mite.StrainTU-A:Plant.GenotypeMoneymaker:Trial3 -20.63542   15.50403
##                                                 t value Pr(>|t|)    
## (Intercept)                                       0.215 0.830337    
## Mite.StrainTU-A                                   6.157 1.02e-08 ***
## Plant.GenotypeHeinz                               0.042 0.966842    
## Plant.GenotypeMicrotom                           -0.101 0.919893    
## Plant.GenotypeMoneymaker                          0.085 0.932676    
## Trial2                                            0.013 0.989301    
## Trial3                                           -0.034 0.973257    
## Mite.StrainTU-A:Plant.GenotypeHeinz               1.359 0.176779    
## Mite.StrainTU-A:Plant.GenotypeMicrotom           -0.634 0.527443    
## Mite.StrainTU-A:Plant.GenotypeMoneymaker          3.884 0.000169 ***
## Mite.StrainTU-A:Trial2                           -2.676 0.008500 ** 
## Mite.StrainTU-A:Trial3                           -1.597 0.112845    
## Plant.GenotypeHeinz:Trial2                       -0.032 0.974282    
## Plant.GenotypeMicrotom:Trial2                    -0.009 0.993191    
## Plant.GenotypeMoneymaker:Trial2                  -0.102 0.919190    
## Plant.GenotypeHeinz:Trial3                        0.067 0.947081    
## Plant.GenotypeMicrotom:Trial3                     0.012 0.990165    
## Plant.GenotypeMoneymaker:Trial3                  -0.057 0.954632    
## Mite.StrainTU-A:Plant.GenotypeHeinz:Trial2       -1.072 0.286037    
## Mite.StrainTU-A:Plant.GenotypeMicrotom:Trial2     1.078 0.283340    
## Mite.StrainTU-A:Plant.GenotypeMoneymaker:Trial2  -1.344 0.181569    
## Mite.StrainTU-A:Plant.GenotypeHeinz:Trial3       -0.507 0.612903    
## Mite.StrainTU-A:Plant.GenotypeMicrotom:Trial3    -0.462 0.644742    
## Mite.StrainTU-A:Plant.GenotypeMoneymaker:Trial3  -1.331 0.185722    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 13.43 on 120 degrees of freedom
## Multiple R-squared:  0.8045, Adjusted R-squared:  0.767 
## F-statistic: 21.47 on 23 and 120 DF,  p-value: < 2.2e-16
Anova(m.0)
## Anova Table (Type II tests)
## 
## Response: Damage
##                                  Sum Sq  Df  F value    Pr(>F)    
## Mite.Strain                       57735   1 320.2501 < 2.2e-16 ***
## Plant.Genotype                     6105   3  11.2874 1.415e-06 ***
## Trial                              8078   2  22.4029 5.401e-09 ***
## Mite.Strain:Plant.Genotype         5715   3  10.5676 3.224e-06 ***
## Mite.Strain:Trial                  7821   2  21.6924 9.082e-09 ***
## Plant.Genotype:Trial               1857   6   1.7171    0.1227    
## Mite.Strain:Plant.Genotype:Trial   1694   6   1.5657    0.1630    
## Residuals                         21634 120                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# linear model without non-significant 3-way interaction (want to reduce comparisons made in Tukey-Kramer post-hoc test)
m <- lm(Damage ~ Mite.Strain + Plant.Genotype + Trial + Mite.Strain:Plant.Genotype + Mite.Strain:Trial + Plant.Genotype:Trial, data = damage.data)
summary(m)
## 
## Call:
## lm(formula = Damage ~ Mite.Strain + Plant.Genotype + Trial + 
##     Mite.Strain:Plant.Genotype + Mite.Strain:Trial + Plant.Genotype:Trial, 
##     data = damage.data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -58.460  -6.161  -0.086   3.998  42.790 
## 
## Coefficients:
##                                          Estimate Std. Error t value
## (Intercept)                                -1.173      4.811  -0.244
## Mite.StrainTU-A                            52.430      5.555   9.439
## Plant.GenotypeHeinz                         4.403      6.414   0.686
## Plant.GenotypeMicrotom                     -2.372      6.414  -0.370
## Plant.GenotypeMoneymaker                    7.568      6.414   1.180
## Trial2                                      2.697      6.211   0.434
## Trial3                                      4.198      6.211   0.676
## Mite.StrainTU-A:Plant.GenotypeHeinz         6.736      6.414   1.050
## Mite.StrainTU-A:Plant.GenotypeMicrotom     -3.767      6.414  -0.587
## Mite.StrainTU-A:Plant.GenotypeMoneymaker   28.760      6.414   4.484
## Mite.StrainTU-A:Trial2                    -34.518      5.555  -6.214
## Mite.StrainTU-A:Trial3                    -26.427      5.555  -4.757
## Plant.GenotypeHeinz:Trial2                 -8.661      7.856  -1.103
## Plant.GenotypeMicrotom:Trial2               8.260      7.856   1.052
## Plant.GenotypeMoneymaker:Trial2           -11.531      7.856  -1.468
## Plant.GenotypeHeinz:Trial3                 -3.203      7.856  -0.408
## Plant.GenotypeMicrotom:Trial3              -3.448      7.856  -0.439
## Plant.GenotypeMoneymaker:Trial3           -10.943      7.856  -1.393
##                                          Pr(>|t|)    
## (Intercept)                                 0.808    
## Mite.StrainTU-A                          2.55e-16 ***
## Plant.GenotypeHeinz                         0.494    
## Plant.GenotypeMicrotom                      0.712    
## Plant.GenotypeMoneymaker                    0.240    
## Trial2                                      0.665    
## Trial3                                      0.500    
## Mite.StrainTU-A:Plant.GenotypeHeinz         0.296    
## Mite.StrainTU-A:Plant.GenotypeMicrotom      0.558    
## Mite.StrainTU-A:Plant.GenotypeMoneymaker 1.63e-05 ***
## Mite.StrainTU-A:Trial2                   6.94e-09 ***
## Mite.StrainTU-A:Trial3                   5.28e-06 ***
## Plant.GenotypeHeinz:Trial2                  0.272    
## Plant.GenotypeMicrotom:Trial2               0.295    
## Plant.GenotypeMoneymaker:Trial2             0.145    
## Plant.GenotypeHeinz:Trial3                  0.684    
## Plant.GenotypeMicrotom:Trial3               0.661    
## Plant.GenotypeMoneymaker:Trial3             0.166    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 13.61 on 126 degrees of freedom
## Multiple R-squared:  0.7892, Adjusted R-squared:  0.7607 
## F-statistic: 27.74 on 17 and 126 DF,  p-value: < 2.2e-16
Anova(m)
## Anova Table (Type II tests)
## 
## Response: Damage
##                            Sum Sq  Df  F value    Pr(>F)    
## Mite.Strain                 57735   1 311.8491 < 2.2e-16 ***
## Plant.Genotype               6105   3  10.9913 1.842e-06 ***
## Trial                        8078   2  21.8153 7.321e-09 ***
## Mite.Strain:Plant.Genotype   5715   3  10.2904 4.160e-06 ***
## Mite.Strain:Trial            7821   2  21.1233 1.227e-08 ***
## Plant.Genotype:Trial         1857   6   1.6721    0.1331    
## Residuals                   23327 126                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Calculate effect size and display
result.anova<-Anova(m)
ss<-result.anova$"Sum Sq"    ##ss = sum of squares
pes<-ss/(ss+ss[length(ss)])  ##pes = partial e squared
pes[length(pes)]<-""
result.anova$"Part E Sq"<-pes
result.anova
## Anova Table (Type II tests)
## 
## Response: Damage
##                            Sum Sq  Df  F value   Pr(>F) Part E Sq
## Mite.Strain                 57735   1 311.8491 0.000000   0.71223
## Plant.Genotype               6105   3  10.9913 0.000002   0.20742
## Trial                        8078   2  21.8153 0.000000   0.25721
## Mite.Strain:Plant.Genotype   5715   3  10.2904 0.000004   0.19679
## Mite.Strain:Trial            7821   2  21.1233 0.000000   0.25110
## Plant.Genotype:Trial         1857   6   1.6721 0.133129   0.07375
## Residuals                   23327 126
interaction.plot(damage.data$Plant.Genotype, damage.data$Mite.Strain, damage.data$Damage, type="l", leg.bty="o", leg.bg="grey95", lwd=2, ylab="Damage", xlab="Plant Genotype", main="Mite.Strain:Plant.Genotype")

interaction.plot(damage.data$Mite.Strain, damage.data$Trial, damage.data$Damage, type="l", leg.bty="o", leg.bg="grey95", lwd=2, ylab="Damage", xlab="Mite Strain", main="Mite.Strain:Trial")

interaction.plot(damage.data$Plant.Genotype, damage.data$Trial, damage.data$Damage, type="l", leg.bty="o", leg.bg="grey95", lwd=2, ylab="Damage", xlab="Plant Genotype", main="Plant Genotype:Trial")

# perform post-hoc Tukey-Kramer test of contrasts
TukeyHSD(aov(Damage ~ Mite.Strain + Plant.Genotype + Trial + Mite.Strain:Plant.Genotype + Mite.Strain:Trial + Plant.Genotype:Trial, data = damage.data))
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Damage ~ Mite.Strain + Plant.Genotype + Trial + Mite.Strain:Plant.Genotype + Mite.Strain:Trial + Plant.Genotype:Trial, data = damage.data)
## 
## $Mite.Strain
##             diff      lwr     upr p adj
## TU-A-TU 40.04687 35.55905 44.5347     0
## 
## $Plant.Genotype
##                            diff        lwr       upr     p adj
## Heinz-Castlemart       3.815972  -4.534168 12.166112 0.6343748
## Microtom-Castlemart   -2.651042 -11.001182  5.699098 0.8417565
## Moneymaker-Castlemart 14.456597   6.106457 22.806737 0.0000865
## Microtom-Heinz        -6.467014 -14.817154  1.883126 0.1874106
## Moneymaker-Heinz      10.640625   2.290485 18.990765 0.0064368
## Moneymaker-Microtom   17.107639   8.757499 25.457779 0.0000026
## 
## $Trial
##          diff        lwr       upr     p adj
## 2-1 -17.54557 -24.132875 -10.95827 0.0000000
## 3-1 -13.41406 -20.001365  -6.82676 0.0000116
## 3-2   4.13151  -2.455792  10.71881 0.3003297
## 
## $`Mite.Strain:Plant.Genotype`
##                                         diff        lwr        upr
## TU-A:Castlemart-TU:Castlemart    32.11458333  18.133812  46.095354
## TU:Heinz-TU:Castlemart            0.44791667 -13.532854  14.428688
## TU-A:Heinz-TU:Castlemart         39.29861111  25.317840  53.279382
## TU:Microtom-TU:Castlemart        -0.76736111 -14.748132  13.213410
## TU-A:Microtom-TU:Castlemart      27.57986111  13.599090  41.560632
## TU:Moneymaker-TU:Castlemart       0.07638889 -13.904382  14.057160
## TU-A:Moneymaker-TU:Castlemart    60.95138889  46.970618  74.932160
## TU:Heinz-TU-A:Castlemart        -31.66666667 -45.647438 -17.685896
## TU-A:Heinz-TU-A:Castlemart        7.18402778  -6.796743  21.164799
## TU:Microtom-TU-A:Castlemart     -32.88194444 -46.862716 -18.901173
## TU-A:Microtom-TU-A:Castlemart    -4.53472222 -18.515493   9.446049
## TU:Moneymaker-TU-A:Castlemart   -32.03819444 -46.018966 -18.057423
## TU-A:Moneymaker-TU-A:Castlemart  28.83680556  14.856034  42.817577
## TU-A:Heinz-TU:Heinz              38.85069444  24.869923  52.831466
## TU:Microtom-TU:Heinz             -1.21527778 -15.196049  12.765493
## TU-A:Microtom-TU:Heinz           27.13194444  13.151173  41.112716
## TU:Moneymaker-TU:Heinz           -0.37152778 -14.352299  13.609243
## TU-A:Moneymaker-TU:Heinz         60.50347222  46.522701  74.484243
## TU:Microtom-TU-A:Heinz          -40.06597222 -54.046743 -26.085201
## TU-A:Microtom-TU-A:Heinz        -11.71875000 -25.699521   2.262021
## TU:Moneymaker-TU-A:Heinz        -39.22222222 -53.202993 -25.241451
## TU-A:Moneymaker-TU-A:Heinz       21.65277778   7.672007  35.633549
## TU-A:Microtom-TU:Microtom        28.34722222  14.366451  42.327993
## TU:Moneymaker-TU:Microtom         0.84375000 -13.137021  14.824521
## TU-A:Moneymaker-TU:Microtom      61.71875000  47.737979  75.699521
## TU:Moneymaker-TU-A:Microtom     -27.50347222 -41.484243 -13.522701
## TU-A:Moneymaker-TU-A:Microtom    33.37152778  19.390757  47.352299
## TU-A:Moneymaker-TU:Moneymaker    60.87500000  46.894229  74.855771
##                                     p adj
## TU-A:Castlemart-TU:Castlemart   0.0000000
## TU:Heinz-TU:Castlemart          1.0000000
## TU-A:Heinz-TU:Castlemart        0.0000000
## TU:Microtom-TU:Castlemart       0.9999998
## TU-A:Microtom-TU:Castlemart     0.0000004
## TU:Moneymaker-TU:Castlemart     1.0000000
## TU-A:Moneymaker-TU:Castlemart   0.0000000
## TU:Heinz-TU-A:Castlemart        0.0000000
## TU-A:Heinz-TU-A:Castlemart      0.7589948
## TU:Microtom-TU-A:Castlemart     0.0000000
## TU-A:Microtom-TU-A:Castlemart   0.9737029
## TU:Moneymaker-TU-A:Castlemart   0.0000000
## TU-A:Moneymaker-TU-A:Castlemart 0.0000001
## TU-A:Heinz-TU:Heinz             0.0000000
## TU:Microtom-TU:Heinz            0.9999948
## TU-A:Microtom-TU:Heinz          0.0000006
## TU:Moneymaker-TU:Heinz          1.0000000
## TU-A:Moneymaker-TU:Heinz        0.0000000
## TU:Microtom-TU-A:Heinz          0.0000000
## TU-A:Microtom-TU-A:Heinz        0.1717221
## TU:Moneymaker-TU-A:Heinz        0.0000000
## TU-A:Moneymaker-TU-A:Heinz      0.0001308
## TU-A:Microtom-TU:Microtom       0.0000002
## TU:Moneymaker-TU:Microtom       0.9999996
## TU-A:Moneymaker-TU:Microtom     0.0000000
## TU:Moneymaker-TU-A:Microtom     0.0000004
## TU-A:Moneymaker-TU-A:Microtom   0.0000000
## TU-A:Moneymaker-TU:Moneymaker   0.0000000
## 
## $`Mite.Strain:Trial`
##                      diff        lwr       upr     p adj
## TU-A:1-TU:1    60.3619792  48.994489  71.72947 0.0000000
## TU:2-TU:1      -0.2864583 -11.653948  11.08103 0.9999997
## TU-A:2-TU:1    25.5572917  14.189802  36.92478 0.0000000
## TU:3-TU:1      -0.2005208 -11.568011  11.16697 1.0000000
## TU-A:3-TU:1    33.7343750  22.366885  45.10186 0.0000000
## TU:2-TU-A:1   -60.6484375 -72.015927 -49.28095 0.0000000
## TU-A:2-TU-A:1 -34.8046875 -46.172177 -23.43720 0.0000000
## TU:3-TU-A:1   -60.5625000 -71.929990 -49.19501 0.0000000
## TU-A:3-TU-A:1 -26.6276042 -37.995094 -15.26011 0.0000000
## TU-A:2-TU:2    25.8437500  14.476260  37.21124 0.0000000
## TU:3-TU:2       0.0859375 -11.281552  11.45343 1.0000000
## TU-A:3-TU:2    34.0208333  22.653344  45.38832 0.0000000
## TU:3-TU-A:2   -25.7578125 -37.125302 -14.39032 0.0000000
## TU-A:3-TU-A:2   8.1770833  -3.190406  19.54457 0.3034916
## TU-A:3-TU:3    33.9348958  22.567406  45.30239 0.0000000
## 
## $`Plant.Genotype:Trial`
##                                  diff         lwr         upr     p adj
## Heinz:1-Castlemart:1        7.7708333 -10.7292326  26.2708992 0.9617476
## Microtom:1-Castlemart:1    -4.2552083 -22.7552742  14.2448576 0.9997880
## Moneymaker:1-Castlemart:1  21.9479167   3.4478508  40.4479826 0.0069065
## Castlemart:2-Castlemart:1 -14.5625000 -33.0625659   3.9375659 0.2792220
## Heinz:2-Castlemart:1      -15.4531250 -33.9531909   3.0469409 0.2006691
## Microtom:2-Castlemart:1   -10.5572917 -29.0573576   7.9427742 0.7566532
## Moneymaker:2-Castlemart:1  -4.1458333 -22.6458992  14.3542326 0.9998355
## Castlemart:3-Castlemart:1  -9.0156250 -27.5156909   9.4844409 0.8973777
## Heinz:3-Castlemart:1       -4.4479167 -22.9479826  14.0521492 0.9996751
## Microtom:3-Castlemart:1   -16.7187500 -35.2188159   1.7813159 0.1180125
## Moneymaker:3-Castlemart:1   1.9895833 -16.5104826  20.4896492 0.9999999
## Microtom:1-Heinz:1        -12.0260417 -30.5261076   6.4740242 0.5777402
## Moneymaker:1-Heinz:1       14.1770833  -4.3229826  32.6771492 0.3183949
## Castlemart:2-Heinz:1      -22.3333333 -40.8333992  -3.8332674 0.0054113
## Heinz:2-Heinz:1           -23.2239583 -41.7240242  -4.7238924 0.0030316
## Microtom:2-Heinz:1        -18.3281250 -36.8281909   0.1719409 0.0546102
## Moneymaker:2-Heinz:1      -11.9166667 -30.4167326   6.5833992 0.5917282
## Castlemart:3-Heinz:1      -16.7864583 -35.2865242   1.7136076 0.1144866
## Heinz:3-Heinz:1           -12.2187500 -30.7188159   6.2813159 0.5530555
## Microtom:3-Heinz:1        -24.4895833 -42.9896492  -5.9895174 0.0012844
## Moneymaker:3-Heinz:1       -5.7812500 -24.2813159  12.7188159 0.9963931
## Moneymaker:1-Microtom:1    26.2031250   7.7030591  44.7031909 0.0003778
## Castlemart:2-Microtom:1   -10.3072917 -28.8073576   8.1927742 0.7836774
## Heinz:2-Microtom:1        -11.1979167 -29.6979826   7.3021492 0.6818518
## Microtom:2-Microtom:1      -6.3020833 -24.8021492  12.1979826 0.9924800
## Moneymaker:2-Microtom:1     0.1093750 -18.3906909  18.6094409 1.0000000
## Castlemart:3-Microtom:1    -4.7604167 -23.2604826  13.7396492 0.9993808
## Heinz:3-Microtom:1         -0.1927083 -18.6927742  18.3073576 1.0000000
## Microtom:3-Microtom:1     -12.4635417 -30.9636076   6.0365242 0.5217575
## Moneymaker:3-Microtom:1     6.2447917 -12.2552742  24.7448576 0.9930316
## Castlemart:2-Moneymaker:1 -36.5104167 -55.0104826 -18.0103508 0.0000001
## Heinz:2-Moneymaker:1      -37.4010417 -55.9011076 -18.9009758 0.0000000
## Microtom:2-Moneymaker:1   -32.5052083 -51.0052742 -14.0051424 0.0000025
## Moneymaker:2-Moneymaker:1 -26.0937500 -44.5938159  -7.5936841 0.0004093
## Castlemart:3-Moneymaker:1 -30.9635417 -49.4636076 -12.4634758 0.0000092
## Heinz:3-Moneymaker:1      -26.3958333 -44.8958992  -7.8957674 0.0003279
## Microtom:3-Moneymaker:1   -38.6666667 -57.1667326 -20.1666008 0.0000000
## Moneymaker:3-Moneymaker:1 -19.9583333 -38.4583992  -1.4582674 0.0226894
## Heinz:2-Castlemart:2       -0.8906250 -19.3906909  17.6094409 1.0000000
## Microtom:2-Castlemart:2     4.0052083 -14.4948576  22.5052742 0.9998827
## Moneymaker:2-Castlemart:2  10.4166667  -8.0833992  28.9167326 0.7720264
## Castlemart:3-Castlemart:2   5.5468750 -12.9531909  24.0469409 0.9974930
## Heinz:3-Castlemart:2       10.1145833  -8.3854826  28.6146492 0.8035122
## Microtom:3-Castlemart:2    -2.1562500 -20.6563159  16.3438159 0.9999998
## Moneymaker:3-Castlemart:2  16.5520833  -1.9479826  35.0521492 0.1270576
## Microtom:2-Heinz:2          4.8958333 -13.6042326  23.3958992 0.9991951
## Moneymaker:2-Heinz:2       11.3072917  -7.1927742  29.8073576 0.6684490
## Castlemart:3-Heinz:2        6.4375000 -12.0625659  24.9375659 0.9910346
## Heinz:3-Heinz:2            11.0052083  -7.4948576  29.5052742 0.7050736
## Microtom:3-Heinz:2         -1.2656250 -19.7656909  17.2344409 1.0000000
## Moneymaker:3-Heinz:2       17.4427083  -1.0573576  35.9427742 0.0845013
## Moneymaker:2-Microtom:2     6.4114583 -12.0886076  24.9115242 0.9913286
## Castlemart:3-Microtom:2     1.5416667 -16.9583992  20.0417326 1.0000000
## Heinz:3-Microtom:2          6.1093750 -12.3906909  24.6094409 0.9942055
## Microtom:3-Microtom:2      -6.1614583 -24.6615242  12.3386076 0.9937748
## Moneymaker:3-Microtom:2    12.5468750  -5.9531909  31.0469409 0.5111487
## Castlemart:3-Moneymaker:2  -4.8697917 -23.3698576  13.6302742 0.9992341
## Heinz:3-Moneymaker:2       -0.3020833 -18.8021492  18.1979826 1.0000000
## Microtom:3-Moneymaker:2   -12.5729167 -31.0729826   5.9271492 0.5078403
## Moneymaker:3-Moneymaker:2   6.1354167 -12.3646492  24.6354826 0.9939933
## Heinz:3-Castlemart:3        4.5677083 -13.9323576  23.0677742 0.9995811
## Microtom:3-Castlemart:3    -7.7031250 -26.2031909  10.7969409 0.9640767
## Moneymaker:3-Castlemart:3  11.0052083  -7.4948576  29.5052742 0.7050736
## Microtom:3-Heinz:3        -12.2708333 -30.7708992   6.2292326 0.5463855
## Moneymaker:3-Heinz:3        6.4375000 -12.0625659  24.9375659 0.9910346
## Moneymaker:3-Microtom:3    18.7083333   0.2082674  37.2083992 0.0448690

The interaction between Mite.Strain and Trial seems to be due to the fact that there is a lot of variability in the damage done by TU-A mites in the different trials, but the TU mites produced generally the same amount of damage (near zero).

Validate model

damage.data$m.fit <- fitted(m)    # fitted values
damage.data$m.res <- rstandard(m) # Pearson residuals

Residual distribution / Overdispersion

We assumed normal residuals. This is the least important regression assumption but its ca be tested with a qq plot.

ggplot(damage.data, aes(sample = m.res)) + geom_qq() +  geom_abline(intercept = 0, slope = 1) + theme_classic() 

Decent.

Residuals vs fitted values

Testing for:

Linearity - there should be no curvilinear pattern in the residuals.

Equal variance - the vertical spread of the residuals should be constant across all fitted values.

ggplot(damage.data, aes(x = m.fit, y = m.res)) + 
  geom_point() + geom_hline(yintercept = 0) + geom_smooth() + theme_classic()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

Linearity - pretty good - confidence interval includes 0. Fairly even spread of residuals

Residuals vs explanatory variables

Should be centered around 0, if not then model requires another explanatory variable(s), to account for observed variation.

ggplot(damage.data, aes(x = Mite.Strain, y = m.res)) + 
  geom_boxplot() + geom_hline(yintercept = 0) + theme_classic()

ggplot(damage.data, aes(x = Trial, y = m.res)) + 
  geom_boxplot() + geom_hline(yintercept = 0) + theme_classic()

ggplot(damage.data, aes(x = Plant.Genotype, y = m.res)) + 
  geom_boxplot() + geom_hline(yintercept = 0) + theme_classic()