ANOVA

This report presents the results of a linear model analysis for multiple response variables (traits) measured on different genotypes (gen) and blocks (bloc). For each trait, we fit a linear model:

\(Y_{ijk}=\mu+g_i+b_j+e_{ijk}\)

and perform:

Analysis of variance (ANOVA) to test the significance of genotype and block effects.

Shapiro–Wilk test on the residuals to check normality.

Bartlett’s test for homogeneity of variances across genotypes.

Finally, we compute genotype means, overall trait means, and the range (min/max) for each trait.

rm(list=ls())
library(readxl)
dados <- read_xlsx(path="C:\\Users\\os\\Downloads\\dados p Noé.xlsx",sheet="data")
dados$bloc=as.factor(dados$bloc)
dados$gen=as.factor(dados$gen)
str(dados)
## tibble [88 × 9] (S3: tbl_df/tbl/data.frame)
##  $ gen : Factor w/ 22 levels "BR 17 Gurguéia",..: 8 8 8 8 10 10 10 10 16 16 ...
##  $ bloc: Factor w/ 4 levels "1","2","3","4": 1 2 3 4 1 2 3 4 1 2 ...
##  $ ph  : num [1:88] 62 63.4 67.5 58.1 73.9 76.6 67.6 69.8 62.7 60.1 ...
##  $ hf  : num [1:88] 54.3 56.7 64.5 50.2 61.5 57.9 64.4 60.1 54.2 50.6 ...
##  $ pp  : num [1:88] 7.44 6.78 7.56 7.22 7 ...
##  $ pl  : num [1:88] 22.3 22.4 23.2 19.3 19.3 ...
##  $ ng  : num [1:88] 106.7 94.9 105.8 104.3 69.7 ...
##  $ we  : num [1:88] 199 201 206 192 161 ...
##  $ gy  : num [1:88] 1832 1907 1968 1787 1376 ...
head(dados)
## # A tibble: 6 × 9
##   gen     bloc     ph    hf    pp    pl    ng    we    gy
##   <fct>   <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 FCB 208 1      62    54.3  7.44  22.3 107.   199. 1832.
## 2 FCB 208 2      63.4  56.7  6.78  22.4  94.9  201. 1907.
## 3 FCB 208 3      67.5  64.5  7.56  23.2 106.   206. 1968.
## 4 FCB 208 4      58.1  50.2  7.22  19.3 104.   192. 1787.
## 5 FCB 406 1      73.9  61.5  7     19.3  69.7  161. 1376.
## 6 FCB 406 2      76.6  57.9  5     17.5  56.7  159. 1433.
for (i in 3:9) {
  print(names(dados)[i])
  m=lm(dados[[i]]~gen+bloc,data=dados)
  print(anova(m))
  print(shapiro.test(residuals(m)))
  print(bartlett.test(residuals(m)~dados$gen))
  anova(m)$`Mean Sq`[3]/mean(dados[[i]]) #CV
}
## [1] "ph"
## Analysis of Variance Table
## 
## Response: dados[[i]]
##           Df Sum Sq Mean Sq F value    Pr(>F)    
## gen       21 3186.7  151.75  4.0105 9.802e-06 ***
## bloc       3 1516.2  505.39 13.3565 7.540e-07 ***
## Residuals 63 2383.8   37.84                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(m)
## W = 0.98351, p-value = 0.328
## 
## 
##  Bartlett test of homogeneity of variances
## 
## data:  residuals(m) by dados$gen
## Bartlett's K-squared = 19.827, df = 21, p-value = 0.5322
## 
## [1] "hf"
## Analysis of Variance Table
## 
## Response: dados[[i]]
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## gen       21 2334.95 111.188  3.8996 1.455e-05 ***
## bloc       3  570.77 190.255  6.6726 0.0005532 ***
## Residuals 63 1796.32  28.513                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(m)
## W = 0.97774, p-value = 0.1343
## 
## 
##  Bartlett test of homogeneity of variances
## 
## data:  residuals(m) by dados$gen
## Bartlett's K-squared = 16.928, df = 21, p-value = 0.7155
## 
## [1] "pp"
## Analysis of Variance Table
## 
## Response: dados[[i]]
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## gen       21 143.381  6.8277  20.932 < 2.2e-16 ***
## bloc       3   4.656  1.5520   4.758  0.004711 ** 
## Residuals 63  20.550  0.3262                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(m)
## W = 0.98174, p-value = 0.2512
## 
## 
##  Bartlett test of homogeneity of variances
## 
## data:  residuals(m) by dados$gen
## Bartlett's K-squared = 26.643, df = 21, p-value = 0.183
## 
## [1] "pl"
## Analysis of Variance Table
## 
## Response: dados[[i]]
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## gen       21 315.025 15.0012 16.9626 < 2.2e-16 ***
## bloc       3  18.421  6.1403  6.9431 0.0004127 ***
## Residuals 63  55.715  0.8844                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(m)
## W = 0.98877, p-value = 0.6555
## 
## 
##  Bartlett test of homogeneity of variances
## 
## data:  residuals(m) by dados$gen
## Bartlett's K-squared = 31.268, df = 21, p-value = 0.06931
## 
## [1] "ng"
## Analysis of Variance Table
## 
## Response: dados[[i]]
##           Df  Sum Sq Mean Sq F value    Pr(>F)    
## gen       21 17692.5  842.50 14.2662 < 2.2e-16 ***
## bloc       3  1594.9  531.64  9.0024 4.783e-05 ***
## Residuals 63  3720.5   59.06                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(m)
## W = 0.98996, p-value = 0.7416
## 
## 
##  Bartlett test of homogeneity of variances
## 
## data:  residuals(m) by dados$gen
## Bartlett's K-squared = 32.14, df = 21, p-value = 0.05666
## 
## [1] "we"
## Analysis of Variance Table
## 
## Response: dados[[i]]
##           Df Sum Sq Mean Sq F value Pr(>F)    
## gen       21  42154 2007.32 64.2737 <2e-16 ***
## bloc       3    152   50.66  1.6223 0.1931    
## Residuals 63   1968   31.23                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(m)
## W = 0.98569, p-value = 0.4466
## 
## 
##  Bartlett test of homogeneity of variances
## 
## data:  residuals(m) by dados$gen
## Bartlett's K-squared = 12.861, df = 21, p-value = 0.9134
## 
## [1] "gy"
## Analysis of Variance Table
## 
## Response: dados[[i]]
##           Df  Sum Sq Mean Sq F value Pr(>F)    
## gen       21 9145266  435489  48.209 <2e-16 ***
## bloc       3   28510    9503   1.052 0.3759    
## Residuals 63  569102    9033                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(m)
## W = 0.98965, p-value = 0.7191
## 
## 
##  Bartlett test of homogeneity of variances
## 
## data:  residuals(m) by dados$gen
## Bartlett's K-squared = 26.783, df = 21, p-value = 0.1782
library(matrixStats)
medias=aggregate(cbind(ph,hf,pp,pl,ng,we,gy)~gen,data=dados,FUN=mean)
colMaxs(as.matrix(medias[,-1]))
##         ph         hf         pp         pl         ng         we         gy 
##   73.57500   65.75000   10.86000   21.81944  110.84062  241.29446 2269.11796
colMeans(medias[,-1])
##          ph          hf          pp          pl          ng          we 
##   63.354545   55.740909    6.437386   18.808439   79.109248  191.984060 
##          gy 
## 1467.947469
colMins(as.matrix(medias[,-1]))
##         ph         hf         pp         pl         ng         we         gy 
##  52.950000  46.550000   5.111111  15.166667  61.715123 143.429718 944.007184

Scott-Knott test

This script performs the Scott-Knott (SK) clustering test for multiple traits simultaneously using a loop. The SK test is a post-hoc procedure used after ANOVA to compare treatment means and group them into homogeneous clusters.

library(ScottKnott)
for (i in 3:9) {
  print(names(dados)[i])
  frm <- as.formula(paste(names(dados)[i], "~ gen + bloc"))
  print(SK(frm, which="gen", data=dados))
}
## [1] "ph"
## Results
##                Means G1 G2
## P.-de-ouro     73.58  a   
## Novaera        72.53  a   
## FCB 406        71.98  a   
## BRS Guariba    71.75  a   
## FCB 1402       70.40  a   
## FCM 608        66.23  a   
## FCB 2309       66.18  a   
## FCB 1103       66.15  a   
## BR 17 Gurguéia 65.85  a   
## FCB 2007       65.60  a   
## FCB 208        62.75     b
## FCB 508        61.53     b
## FCB 2006       61.33     b
## FCB 2009       60.58     b
## FCM 505        60.50     b
## FCB 601        59.70     b
## FCB 603        59.43     b
## FCM 604        59.00     b
## FCB 509        56.60     b
## FCB 602        54.95     b
## FCM 906        54.28     b
## FCM 609        52.95     b
## 
## Sig.level
##  0.05
## 
## Statistics
##        lambda chisq dfchisq  pvalue evmean dferror
## Clus 1     49    30    19.3 0.00018    9.5      63
## Clus 2     13    17     8.8 0.13941    9.5      63
## Clus 3     14    19    10.5 0.22452    9.5      63
## 
## 
## Clusters
## #################  Cluster  1  ################
## {G1}: P.-de-ouro Novaera FCB 406 BRS Guariba FCB 1402 FCM 608 FCB 2309 FCB 1103 BR 17 Gurguéia FCB 2007
## {G2}: FCB 208 FCB 508 FCB 2006 FCB 2009 FCM 505 FCB 601 FCB 603 FCM 604 FCB 509 FCB 602 FCM 906 FCM 609
## #################  Cluster  2  ################
## {G1}: P.-de-ouro Novaera FCB 406 BRS Guariba FCB 1402
## {G2}: FCM 608 FCB 2309 FCB 1103 BR 17 Gurguéia FCB 2007
## #################  Cluster  3  ################
## {G1}: FCB 208 FCB 508 FCB 2006 FCB 2009 FCM 505 FCB 601 FCB 603 FCM 604
## {G2}: FCB 509 FCB 602 FCM 906 FCM 609
## [1] "hf"
## Results
##                Means G1 G2
## P.-de-ouro     65.75  a   
## FCB 1402       62.95  a   
## Novaera        62.20  a   
## FCB 406        60.97  a   
## FCB 1103       59.45  a   
## FCM 608        59.42  a   
## FCB 2007       59.35  a   
## BR 17 Gurguéia 58.87  a   
## FCB 2309       57.97  a   
## FCB 208        56.42  a   
## BRS Guariba    56.05  a   
## FCB 2006       55.73  a   
## FCB 508        55.25  a   
## FCB 601        55.25  a   
## FCB 2009       53.82     b
## FCB 603        53.55     b
## FCM 604        51.45     b
## FCM 505        50.25     b
## FCB 509        48.72     b
## FCM 609        48.52     b
## FCB 602        47.77     b
## FCM 906        46.55     b
## 
## Sig.level
##  0.05
## 
## Statistics
##        lambda chisq dfchisq  pvalue evmean dferror
## Clus 1   45.6    30      19 0.00064    7.1      63
## Clus 2   16.3    21      12 0.19119    7.1      63
## Clus 3    7.7    14       7 0.36173    7.1      63
## 
## 
## Clusters
## #################  Cluster  1  ################
## {G1}: P.-de-ouro FCB 1402 Novaera FCB 406 FCB 1103 FCM 608 FCB 2007 BR 17 Gurguéia FCB 2309 FCB 208 BRS Guariba FCB 2006 FCB 508 FCB 601
## {G2}: FCB 2009 FCB 603 FCM 604 FCM 505 FCB 509 FCM 609 FCB 602 FCM 906
## #################  Cluster  2  ################
## {G1}: P.-de-ouro FCB 1402 Novaera FCB 406
## {G2}: FCB 1103 FCM 608 FCB 2007 BR 17 Gurguéia FCB 2309 FCB 208 BRS Guariba FCB 2006 FCB 508 FCB 601
## #################  Cluster  3  ################
## {G1}: FCB 2009 FCB 603 FCM 604
## {G2}: FCM 505 FCB 509 FCM 609 FCB 602 FCM 906
## [1] "pp"
## Results
##                Means G1 G2 G3 G4
## FCB 601        10.86  a         
## FCM 608         8.43     b      
## FCB 508         8.22     b      
## FCB 208         7.25        c   
## FCM 505         6.83        c   
## FCM 609         6.61        c   
## P.-de-ouro      6.56        c   
## FCB 2309        6.33        c   
## FCB 602         6.28        c   
## FCB 509         6.19        c   
## FCB 2006        6.06           d
## FCB 1103        6.01           d
## FCM 906         6.00           d
## FCB 2009        5.95           d
## FCB 406         5.86           d
## FCM 604         5.81           d
## Novaera         5.61           d
## FCB 2007        5.58           d
## FCB 603         5.50           d
## BR 17 Gurguéia  5.39           d
## FCB 1402        5.19           d
## BRS Guariba     5.11           d
## 
## Sig.level
##  0.05
## 
## Statistics
##        lambda chisq dfchisq  pvalue evmean dferror
## Clus 1  73.97  30.5    19.3 2.4e-08  0.082      63
## Clus 2  41.23   7.2     2.6 3.3e-09  0.082      63
## Clus 3   0.36   5.5     1.8 7.9e-01  0.082      63
## Clus 4  38.15  27.1    16.6 2.0e-03  0.082      63
## Clus 5   9.70  12.8     6.1 1.5e-01  0.082      63
## Clus 6  14.79  19.0    10.5 1.7e-01  0.082      63
## 
## 
## Clusters
## #################  Cluster  1  ################
## {G1}: FCB 601 FCM 608 FCB 508
## {G2}: FCB 208 FCM 505 FCM 609 P.-de-ouro FCB 2309 FCB 602 FCB 509 FCB 2006 FCB 1103 FCM 906 FCB 2009 FCB 406 FCM 604 Novaera FCB 2007 FCB 603 BR 17 Gurguéia FCB 1402 BRS Guariba
## #################  Cluster  2  ################
## {G1}: FCB 601
## {G2}: FCM 608 FCB 508
## #################  Cluster  3  ################
## {G1}: FCM 608
## {G2}: FCB 508
## #################  Cluster  4  ################
## {G1}: FCB 208 FCM 505 FCM 609 P.-de-ouro FCB 2309 FCB 602 FCB 509
## {G2}: FCB 2006 FCB 1103 FCM 906 FCB 2009 FCB 406 FCM 604 Novaera FCB 2007 FCB 603 BR 17 Gurguéia FCB 1402 BRS Guariba
## #################  Cluster  5  ################
## {G1}: FCB 208 FCM 505
## {G2}: FCM 609 P.-de-ouro FCB 2309 FCB 602 FCB 509
## #################  Cluster  6  ################
## {G1}: FCB 2006 FCB 1103 FCM 906 FCB 2009 FCB 406 FCM 604
## {G2}: Novaera FCB 2007 FCB 603 BR 17 Gurguéia FCB 1402 BRS Guariba
## [1] "pl"
## Results
##                Means G1 G2 G3 G4
## FCB 208        21.82  a         
## FCB 508        21.51  a         
## BR 17 Gurguéia 21.16  a         
## FCM 608        21.16  a         
## FCM 604        21.04  a         
## FCB 2009       20.91  a         
## FCB 2309       20.60  a         
## FCM 505        19.72     b      
## P.-de-ouro     19.27     b      
## FCB 2007       19.06     b      
## FCB 2006       18.95     b      
## Novaera        18.47        c   
## FCB 1402       17.64        c   
## FCB 509        17.63        c   
## FCB 406        17.61        c   
## FCB 603        17.61        c   
## BRS Guariba    17.20        c   
## FCM 906        16.93        c   
## FCB 1103       16.93        c   
## FCB 602        16.86        c   
## FCM 609        16.54        c   
## FCB 601        15.17           d
## 
## Sig.level
##  0.05
## 
## Statistics
##        lambda chisq dfchisq  pvalue evmean dferror
## Clus 1   76.9  30.5    19.3 7.7e-09   0.22      63
## Clus 2   38.9  17.8     9.6 2.0e-05   0.22      63
## Clus 3    4.4  12.8     6.1 6.4e-01   0.22      63
## Clus 4    1.9   8.7     3.5 6.7e-01   0.22      63
## Clus 5   20.8  17.8     9.6 1.9e-02   0.22      63
## Clus 6   12.1  16.6     8.8 1.9e-01   0.22      63
## 
## 
## Clusters
## #################  Cluster  1  ################
## {G1}: FCB 208 FCB 508 BR 17 Gurguéia FCM 608 FCM 604 FCB 2009 FCB 2309 FCM 505 P.-de-ouro FCB 2007 FCB 2006
## {G2}: Novaera FCB 1402 FCB 509 FCB 406 FCB 603 BRS Guariba FCM 906 FCB 1103 FCB 602 FCM 609 FCB 601
## #################  Cluster  2  ################
## {G1}: FCB 208 FCB 508 BR 17 Gurguéia FCM 608 FCM 604 FCB 2009 FCB 2309
## {G2}: FCM 505 P.-de-ouro FCB 2007 FCB 2006
## #################  Cluster  3  ################
## {G1}: FCB 208 FCB 508
## {G2}: BR 17 Gurguéia FCM 608 FCM 604 FCB 2009 FCB 2309
## #################  Cluster  4  ################
## {G1}: FCM 505
## {G2}: P.-de-ouro FCB 2007 FCB 2006
## #################  Cluster  5  ################
## {G1}: Novaera FCB 1402 FCB 509 FCB 406 FCB 603 BRS Guariba FCM 906 FCB 1103 FCB 602 FCM 609
## {G2}: FCB 601
## #################  Cluster  6  ################
## {G1}: Novaera FCB 1402 FCB 509 FCB 406 FCB 603
## {G2}: BRS Guariba FCM 906 FCB 1103 FCB 602 FCM 609
## [1] "ng"
## Results
##                 Means G1 G2 G3 G4
## FCB 508        110.84  a         
## FCM 608        110.56  a         
## FCB 208        102.92  a         
## FCM 609         92.49     b      
## FCM 505         92.11     b      
## FCB 2309        87.05     b      
## FCB 601         82.58        c   
## P.-de-ouro      79.61        c   
## FCM 604         78.11        c   
## FCB 2009        77.75        c   
## FCB 602         75.14        c   
## FCB 509         75.06        c   
## BR 17 Gurguéia  71.12           d
## FCB 2006        70.86           d
## FCB 406         69.74           d
## FCM 906         69.08           d
## FCB 1103        69.02           d
## Novaera         67.23           d
## FCB 1402        67.04           d
## FCB 603         66.35           d
## BRS Guariba     64.03           d
## FCB 2007        61.72           d
## 
## Sig.level
##  0.05
## 
## Statistics
##        lambda chisq dfchisq  pvalue evmean dferror
## Clus 1   73.7  30.5    19.3 2.7e-08     15      63
## Clus 2   30.2  11.5     5.3 1.7e-05     15      63
## Clus 3    3.8   7.2     2.6 2.3e-01     15      63
## Clus 4    1.8   7.2     2.6 5.5e-01     15      63
## Clus 5   30.3  23.7    14.0 6.9e-03     15      63
## Clus 6    2.7  11.5     5.3 7.7e-01     15      63
## Clus 7    5.6  16.6     8.8 7.6e-01     15      63
## 
## 
## Clusters
## #################  Cluster  1  ################
## {G1}: FCB 508 FCM 608 FCB 208 FCM 609 FCM 505 FCB 2309
## {G2}: FCB 601 P.-de-ouro FCM 604 FCB 2009 FCB 602 FCB 509 BR 17 Gurguéia FCB 2006 FCB 406 FCM 906 FCB 1103 Novaera FCB 1402 FCB 603 BRS Guariba FCB 2007
## #################  Cluster  2  ################
## {G1}: FCB 508 FCM 608 FCB 208
## {G2}: FCM 609 FCM 505 FCB 2309
## #################  Cluster  3  ################
## {G1}: FCB 508 FCM 608
## {G2}: FCB 208
## #################  Cluster  4  ################
## {G1}: FCM 609 FCM 505
## {G2}: FCB 2309
## #################  Cluster  5  ################
## {G1}: FCB 601 P.-de-ouro FCM 604 FCB 2009 FCB 602 FCB 509
## {G2}: BR 17 Gurguéia FCB 2006 FCB 406 FCM 906 FCB 1103 Novaera FCB 1402 FCB 603 BRS Guariba FCB 2007
## #################  Cluster  6  ################
## {G1}: FCB 601 P.-de-ouro
## {G2}: FCM 604 FCB 2009 FCB 602 FCB 509
## #################  Cluster  7  ################
## {G1}: BR 17 Gurguéia FCB 2006 FCB 406 FCM 906 FCB 1103 Novaera FCB 1402 FCB 603
## {G2}: BRS Guariba FCB 2007
## [1] "we"
## Results
##                 Means G1 G2 G3 G4 G5 G6 G7
## FCB 508        241.29  a                  
## BRS Guariba    214.56     b               
## FCB 601        214.11     b               
## Novaera        213.86     b               
## FCB 603        210.03     b               
## FCM 505        209.45     b               
## FCB 208        199.52        c            
## FCM 608        198.02        c            
## FCM 604        196.84        c            
## P.-de-ouro     196.68        c            
## FCB 509        196.42        c            
## FCB 1103       194.04        c            
## BR 17 Gurguéia 193.09        c            
## FCM 609        192.44        c            
## FCB 1402       185.07           d         
## FCB 2309       183.72           d         
## FCB 2006       182.25           d         
## FCB 2009       175.28              e      
## FCB 602        170.35              e      
## FCB 406        159.37                 f   
## FCB 2007       153.84                 f   
## FCM 906        143.43                    g
## 
## Sig.level
##  0.05
## 
## Statistics
##         lambda chisq dfchisq  pvalue evmean dferror
## Clus 1   69.42  30.5    19.3 1.4e-07    7.8      63
## Clus 2   58.75  21.4    12.3 4.8e-08    7.8      63
## Clus 3   54.51  11.5     5.3 2.3e-10    7.8      63
## Clus 4    4.28  10.1     4.4 4.2e-01    7.8      63
## Clus 5    6.35  14.1     7.0 5.0e-01    7.8      63
## Clus 6   62.37  14.1     7.0 5.1e-11    7.8      63
## Clus 7   20.41  10.1     4.4 6.0e-04    7.8      63
## Clus 8    0.56   7.2     2.6 8.6e-01    7.8      63
## Clus 9    2.16   5.5     1.8 2.9e-01    7.8      63
## Clus 10  16.87   7.2     2.6 4.9e-04    7.8      63
## Clus 11   2.70   5.5     1.8 2.2e-01    7.8      63
## 
## 
## Clusters
## #################  Cluster  1  ################
## {G1}: FCB 508 BRS Guariba FCB 601 Novaera FCB 603 FCM 505 FCB 208 FCM 608 FCM 604 P.-de-ouro FCB 509 FCB 1103 BR 17 Gurguéia FCM 609
## {G2}: FCB 1402 FCB 2309 FCB 2006 FCB 2009 FCB 602 FCB 406 FCB 2007 FCM 906
## #################  Cluster  2  ################
## {G1}: FCB 508 BRS Guariba FCB 601 Novaera FCB 603 FCM 505
## {G2}: FCB 208 FCM 608 FCM 604 P.-de-ouro FCB 509 FCB 1103 BR 17 Gurguéia FCM 609
## #################  Cluster  3  ################
## {G1}: FCB 508
## {G2}: BRS Guariba FCB 601 Novaera FCB 603 FCM 505
## #################  Cluster  4  ################
## {G1}: BRS Guariba FCB 601 Novaera
## {G2}: FCB 603 FCM 505
## #################  Cluster  5  ################
## {G1}: FCB 208 FCM 608 FCM 604 P.-de-ouro FCB 509
## {G2}: FCB 1103 BR 17 Gurguéia FCM 609
## #################  Cluster  6  ################
## {G1}: FCB 1402 FCB 2309 FCB 2006 FCB 2009 FCB 602
## {G2}: FCB 406 FCB 2007 FCM 906
## #################  Cluster  7  ################
## {G1}: FCB 1402 FCB 2309 FCB 2006
## {G2}: FCB 2009 FCB 602
## #################  Cluster  8  ################
## {G1}: FCB 1402 FCB 2309
## {G2}: FCB 2006
## #################  Cluster  9  ################
## {G1}: FCB 2009
## {G2}: FCB 602
## #################  Cluster  10  ################
## {G1}: FCB 406 FCB 2007
## {G2}: FCM 906
## #################  Cluster  11  ################
## {G1}: FCB 406
## {G2}: FCB 2007
## [1] "gy"
## Results
##                  Means G1 G2 G3 G4 G5 G6 G7
## FCB 601        2269.12  a                  
## FCB 508        1925.30     b               
## FCB 208        1873.65     b               
## FCM 505        1802.30     b               
## FCM 608        1666.55        c            
## FCM 609        1659.11        c            
## P.-de-ouro     1605.12        c            
## FCB 2309       1568.07        c            
## FCB 602        1540.25        c            
## FCB 603        1540.08        c            
## FCB 2007       1513.42        c            
## FCB 406        1454.41           d         
## FCB 2009       1376.64           d         
## Novaera        1375.00           d         
## BR 17 Gurguéia 1341.29           d         
## FCM 604        1300.69              e      
## FCB 1402       1224.42              e      
## BRS Guariba    1209.53              e      
## FCB 1103       1145.35                 f   
## FCM 906         984.62                    g
## FCB 509         975.91                    g
## FCB 2006        944.01                    g
## 
## Sig.level
##  0.05
## 
## Statistics
##         lambda chisq dfchisq  pvalue evmean dferror
## Clus 1   69.41  30.5    19.3 1.4e-07   2258      63
## Clus 2   57.03  17.8     9.6 9.3e-09   2258      63
## Clus 3   41.22   8.7     3.5 1.2e-08   2258      63
## Clus 4    3.81   7.2     2.6 2.3e-01   2258      63
## Clus 5   10.69  12.8     6.1 1.0e-01   2258      63
## Clus 6   55.01  17.8     9.6 2.2e-08   2258      63
## Clus 7   17.65  12.8     6.1 7.8e-03   2258      63
## Clus 8    3.76   8.7     3.5 3.6e-01   2258      63
## Clus 9    2.89   7.2     2.6 3.4e-01   2258      63
## Clus 10  13.02   8.7     3.5 7.4e-03   2258      63
## Clus 11   0.56   7.2     2.6 8.6e-01   2258      63
## 
## 
## Clusters
## #################  Cluster  1  ################
## {G1}: FCB 601 FCB 508 FCB 208 FCM 505 FCM 608 FCM 609 P.-de-ouro FCB 2309 FCB 602 FCB 603 FCB 2007
## {G2}: FCB 406 FCB 2009 Novaera BR 17 Gurguéia FCM 604 FCB 1402 BRS Guariba FCB 1103 FCM 906 FCB 509 FCB 2006
## #################  Cluster  2  ################
## {G1}: FCB 601 FCB 508 FCB 208 FCM 505
## {G2}: FCM 608 FCM 609 P.-de-ouro FCB 2309 FCB 602 FCB 603 FCB 2007
## #################  Cluster  3  ################
## {G1}: FCB 601
## {G2}: FCB 508 FCB 208 FCM 505
## #################  Cluster  4  ################
## {G1}: FCB 508 FCB 208
## {G2}: FCM 505
## #################  Cluster  5  ################
## {G1}: FCM 608 FCM 609 P.-de-ouro
## {G2}: FCB 2309 FCB 602 FCB 603 FCB 2007
## #################  Cluster  6  ################
## {G1}: FCB 406 FCB 2009 Novaera BR 17 Gurguéia FCM 604 FCB 1402 BRS Guariba
## {G2}: FCB 1103 FCM 906 FCB 509 FCB 2006
## #################  Cluster  7  ################
## {G1}: FCB 406 FCB 2009 Novaera BR 17 Gurguéia
## {G2}: FCM 604 FCB 1402 BRS Guariba
## #################  Cluster  8  ################
## {G1}: FCB 406
## {G2}: FCB 2009 Novaera BR 17 Gurguéia
## #################  Cluster  9  ################
## {G1}: FCM 604
## {G2}: FCB 1402 BRS Guariba
## #################  Cluster  10  ################
## {G1}: FCB 1103
## {G2}: FCM 906 FCB 509 FCB 2006
## #################  Cluster  11  ################
## {G1}: FCM 906 FCB 509
## {G2}: FCB 2006

MGIDI and Smith-Hazel indices

This script computes the MGIDI (multi-trait genotype-ideotype distance index) to rank genotypes based on predefined economic weights. The KMO (Kaiser-Meyer-Olkin) test is applied to the MGIDI correlation matrix to verify the adequacy of the factor analysis structure. The classical Smith-Hazel linear selection index is also calculated using the phenotypic and genotypic covariance matrices. Both indices use identical weights and a fixed selection intensity of 20 % (SI = 20) to ensure a fair comparison. Finally, the coincidence index measures the agreement between the genotypes selected by MGIDI and Smith-Hazel.

library(metan)
## Registered S3 method overwritten by 'GGally':
##   method from   
##   +.gg   ggplot2
## |=========================================================|
## | Multi-Environment Trial Analysis (metan) v1.18.0        |
## | Author: Tiago Olivoto                                   |
## | Type 'citation('metan')' to know how to cite metan      |
## | Type 'vignette('metan_start')' for a short tutorial     |
## | Visit 'https://bit.ly/pkgmetan' for a complete tutorial |
## |=========================================================|
library(psych)
## 
## Attaching package: 'psych'
## The following object is masked from 'package:metan':
## 
##     skew
mod=gafem(.data=dados,gen=gen,rep=bloc,resp=c(ph,hf,pp,pl,ng,we,gy))
## Evaluating trait ph |======                                      | 14% 00:00:00 Evaluating trait hf |=============                               | 29% 00:00:00 Evaluating trait pp |===================                         | 43% 00:00:00 Evaluating trait pl |=========================                   | 57% 00:00:01 Evaluating trait ng |===============================             | 71% 00:00:01 Evaluating trait we |======================================      | 86% 00:00:01 Evaluating trait gy |============================================| 100% 00:00:01 
## ---------------------------------------------------------------------------
## One-way ANOVA table (Randomized complete block design)
## ---------------------------------------------------------------------------
##      model       ph       hf       pp       pl       ng       we       gy
##        REP 7.54e-07 5.53e-04 4.71e-03 4.13e-04 4.78e-05 1.93e-01 3.76e-01
##        GEN 9.80e-06 1.45e-05 7.27e-21 1.69e-18 1.26e-16 1.19e-34 5.60e-31
##  Residuals       NA       NA       NA       NA       NA       NA       NA
## ---------------------------------------------------------------------------
## Variables with nonsignificant genotype effect
##  
## ---------------------------------------------------------------------------
mg=mgidi(mod,weights=c(0.2,1,1,1,1,1,1),SI=20)
## 
## -------------------------------------------------------------------------------
## Principal Component Analysis
## -------------------------------------------------------------------------------
## # A tibble: 7 × 4
##   PC    Eigenvalues `Variance (%)` `Cum. variance (%)`
##   <chr>       <dbl>          <dbl>               <dbl>
## 1 PC1          2.79          39.8                 39.8
## 2 PC2          2.05          29.3                 69.2
## 3 PC3          1.07          15.2                 84.4
## 4 PC4          0.65           9.26                93.7
## 5 PC5          0.25           3.55                97.2
## 6 PC6          0.14           1.95                99.2
## 7 PC7          0.06           0.83               100  
## -------------------------------------------------------------------------------
## Factor Analysis - factorial loadings after rotation-
## -------------------------------------------------------------------------------
## # A tibble: 7 × 6
##   VAR     FA1   FA2   FA3 Communality Uniquenesses
##   <chr> <dbl> <dbl> <dbl>       <dbl>        <dbl>
## 1 ph     0.07 -0.98 -0.04        0.96         0.04
## 2 hf    -0.05 -0.97 -0.07        0.94         0.06
## 3 pp    -0.91  0.17  0.08        0.86         0.14
## 4 pl    -0.05 -0.14 -0.97        0.96         0.04
## 5 ng    -0.72  0.22 -0.58        0.89         0.11
## 6 we    -0.65 -0.19 -0.17        0.48         0.52
## 7 gy    -0.9  -0.02 -0.05        0.81         0.19
## -------------------------------------------------------------------------------
## Comunalit Mean: 0.8441209 
## -------------------------------------------------------------------------------
## Selection differential 
## -------------------------------------------------------------------------------
## # A tibble: 7 × 11
##   VAR   Factor      Xo      Xs      SD SDperc    h2      SG SGperc sense    goal
##   <chr> <chr>    <dbl>   <dbl>   <dbl>  <dbl> <dbl>   <dbl>  <dbl> <chr>   <dbl>
## 1 pp    FA1       6.44    7.68   1.25  19.3   0.952   1.19  18.4   increa…   100
## 2 ng    FA1      79.1   104.    25.0   31.6   0.930  23.2   29.4   increa…   100
## 3 we    FA1     192.    212.    20.1   10.5   0.984  19.8   10.3   increa…   100
## 4 gy    FA1    1468.   1817.   349.    23.8   0.979 342.    23.3   increa…   100
## 5 ph    FA2      63.4    62.8   -0.605 -0.954 0.751  -0.454 -0.716 increa…     0
## 6 hf    FA2      55.7    55.3   -0.403 -0.724 0.744  -0.300 -0.538 increa…     0
## 7 pl    FA3      18.8    21.1    2.24  11.9   0.941   2.11  11.2   increa…   100
## ------------------------------------------------------------------------------
## Selected genotypes
## -------------------------------------------------------------------------------
## FCB 508 FCM 608 FCB 208 FCM 505
## -------------------------------------------------------------------------------
print(mg)
## -------------------------------------------------------------------------------
## Correlation matrix used used in factor analysis 
## -------------------------------------------------------------------------------
##        ph     hf     pp    pl    ng   we     gy
## ph  1.000  0.919 -0.230  0.16 -0.22 0.12 -0.042
## hf  0.919  1.000 -0.074  0.21 -0.12 0.11  0.079
## pp -0.230 -0.074  1.000 -0.03  0.65 0.39  0.753
## pl  0.161  0.211 -0.030  1.00  0.52 0.18  0.135
## ng -0.216 -0.116  0.655  0.52  1.00 0.44  0.624
## we  0.125  0.114  0.387  0.18  0.44 1.00  0.443
## gy -0.042  0.079  0.753  0.13  0.62 0.44  1.000
## -------------------------------------------------------------------------------
## Principal component analysis 
## -------------------------------------------------------------------------------
## # A tibble: 7 × 4
##   PC    Eigenvalues `Variance (%)` `Cum. variance (%)`
##   <chr>       <dbl>          <dbl>               <dbl>
## 1 PC1       2.788          39.82                 39.82
## 2 PC2       2.054          29.34                 69.17
## 3 PC3       1.067          15.25                 84.41
## 4 PC4       0.6479          9.256                93.67
## 5 PC5       0.2485          3.550                97.22
## 6 PC6       0.1364          1.948                99.17
## 7 PC7       0.05838         0.8340              100   
## -------------------------------------------------------------------------------
## Initial loadings 
## -------------------------------------------------------------------------------
## # A tibble: 7 × 4
##   VAR        PC1      PC2     PC3
##   <chr>    <dbl>    <dbl>   <dbl>
## 1 ph     0.2011  -0.9481   0.1531
## 2 hf     0.07740 -0.9514   0.1686
## 3 pp    -0.8437   0.1266   0.3586
## 4 pl    -0.3434  -0.3892  -0.8331
## 5 ng    -0.8903   0.01616 -0.3186
## 6 we    -0.6299  -0.2694   0.1190
## 7 gy    -0.8498  -0.09670  0.2777
## -------------------------------------------------------------------------------
## Loadings after varimax rotation 
## -------------------------------------------------------------------------------
## # A tibble: 7 × 4
##   VAR        FA1      FA2      FA3
##   <chr>    <dbl>    <dbl>    <dbl>
## 1 ph     0.06967 -0.9779  -0.03987
## 2 hf    -0.05137 -0.9657  -0.06727
## 3 pp    -0.9057   0.1723   0.08166
## 4 pl    -0.04973 -0.1403  -0.9702 
## 5 ng    -0.7155   0.2212  -0.5774 
## 6 we    -0.6475  -0.1896  -0.1682 
## 7 gy    -0.8974  -0.02431 -0.05159
## -------------------------------------------------------------------------------
## Scores for genotypes-ideotype 
## -------------------------------------------------------------------------------
## # A tibble: 23 × 4
##    GEN                FA1    FA2     FA3
##    <chr>            <dbl>  <dbl>   <dbl>
##  1 BR 17 Gurguéia -0.9483 -2.373 -2.384 
##  2 BRS Guariba    -1.156  -2.749 -0.6532
##  3 FCB 1103       -1.230  -2.439 -0.5479
##  4 FCB 1402       -0.9393 -3.098 -0.8501
##  5 FCB 2006       -0.6903 -1.595 -1.541 
##  6 FCB 2007       -0.7968 -2.304 -1.161 
##  7 FCB 2009       -0.9886 -1.336 -2.397 
##  8 FCB 208        -2.534  -1.711 -2.992 
##  9 FCB 2309       -1.632  -2.150 -2.316 
## 10 FCB 406        -1.129  -2.907 -0.7026
## # ℹ 13 more rows
## -------------------------------------------------------------------------------
## Multi-trait genotype-ideotype distance index 
## -------------------------------------------------------------------------------
## # A tibble: 22 × 2
##    Genotype   MGIDI
##    <chr>      <dbl>
##  1 FCB 508    1.503
##  2 FCM 608    1.972
##  3 FCB 208    2.370
##  4 FCM 505    2.677
##  5 FCB 2309   3.141
##  6 P.-de-ouro 3.224
##  7 FCB 601    3.500
##  8 FCM 609    3.639
##  9 FCB 603    3.689
## 10 Novaera    3.701
## # ℹ 12 more rows
## -------------------------------------------------------------------------------
## Selection differential 
## -------------------------------------------------------------------------------
## # A tibble: 7 × 11
##   VAR   Factor       Xo       Xs       SD  SDperc     h2       SG  SGperc sense 
##   <chr> <chr>     <dbl>    <dbl>    <dbl>   <dbl>  <dbl>    <dbl>   <dbl> <chr> 
## 1 pp    FA1       6.437    7.683   1.245  19.34   0.9522   1.186  18.42   incre…
## 2 ng    FA1      79.11   104.1    25.00   31.60   0.9299  23.25   29.39   incre…
## 3 we    FA1     192.0    212.1    20.09   10.46   0.9844  19.77   10.30   incre…
## 4 gy    FA1    1468.    1817.    349.0    23.77   0.9793 341.8    23.28   incre…
## 5 ph    FA2      63.35    62.75   -0.6045 -0.9542 0.7507  -0.4538 -0.7163 incre…
## 6 hf    FA2      55.74    55.34   -0.4034 -0.7237 0.7436  -0.3000 -0.5381 incre…
## 7 pl    FA3      18.81    21.05    2.244  11.93   0.9410   2.112  11.23   incre…
## # ℹ 1 more variable: goal <dbl>
## -------------------------------------------------------------------------------
## Selected genotypes 
## -------------------------------------------------------------------------------
## FCB 508 FCM 608 FCB 208 FCM 505
print(KMO(mg$cormat))
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = mg$cormat)
## Overall MSA =  0.55
## MSA for each item = 
##   ph   hf   pp   pl   ng   we   gy 
## 0.49 0.46 0.55 0.31 0.60 0.78 0.81
vcov <- covcor_design(.data = dados,gen = gen,rep = bloc,
                      resp = c(ph, hf, pp, pl, ng, we, gy)) 
means <- as.matrix(vcov$means)
pcov <- vcov$phen_cov
gcov <- vcov$geno_cov
sh=Smith_Hazel(means,use_data = "pheno",pcov = pcov,
                     gcov = gcov,SI=20, weights = c(0.2,1,1,1,1,1,1))
print(sh)
## 
## -----------------------------------------------------------------------------------
## Index coefficients
## -----------------------------------------------------------------------------------
## # A tibble: 7 × 3
##   VAR        b gen_weights
##   <chr>  <dbl>       <dbl>
## 1 ph    0.2589         0.2
## 2 hf    0.6203         1  
## 3 pp    6.502          1  
## 4 pl    1.545          1  
## 5 ng    1.137          1  
## 6 we    0.9914         1  
## 7 gy    0.9643         1  
## 
## -----------------------------------------------------------------------------------
## Genetic worth
## -----------------------------------------------------------------------------------
##               GEN       V1
## 1         FCB 601 2638.112
## 2         FCB 508 2358.756
## 3         FCB 208 2253.734
## 4         FCM 505 2172.130
## 5         FCM 608 2070.611
## 6         FCM 609 2008.206
## 7      P.-de-ouro 1965.605
## 8        FCB 2309 1919.342
## 9         FCB 603 1880.382
## 10        FCB 602 1850.344
## 11       FCB 2007 1801.665
## 12        FCB 406 1761.602
## 13        Novaera 1736.793
## 14       FCB 2009 1709.729
## 15 BR 17 Gurguéia 1687.042
## 16        FCM 604 1655.692
## 17    BRS Guariba 1565.049
## 18       FCB 1402 1558.737
## 19       FCB 1103 1494.570
## 20        FCB 509 1333.561
## 21       FCB 2006 1290.686
## 22        FCM 906 1278.339
## 
## -----------------------------------------------------------------------------------
## Selection gain
## -----------------------------------------------------------------------------------
## # A tibble: 7 × 7
##   VAR         Xo       Xs       SD SDperc sense     goal
##   <chr>    <dbl>    <dbl>    <dbl>  <dbl> <chr>    <dbl>
## 1 ph      63.35    61.12   -2.236  -3.529 increase     0
## 2 hf      55.74    54.29   -1.447  -2.596 increase     0
## 3 pp       6.437    8.291   1.854  28.80  increase   100
## 4 pl      18.81    19.55    0.7457  3.965 increase   100
## 5 ng      79.11    97.12   18.01   22.76  increase   100
## 6 we     192.0    216.1    24.11   12.56  increase   100
## 7 gy    1468.    1968.    499.6    34.04  increase   100
## 
## -----------------------------------------------------------------------------------
## Phenotypic variance-covariance matrix
## -----------------------------------------------------------------------------------
##       ph     hf      pp     pl     ng     we     gy
## ph  50.6  29.84  -1.852  1.919  -19.3   17.2    -86
## hf  29.8  37.06  -0.507  2.149   -8.8   13.4    138
## pp  -1.9  -0.51   2.276 -0.076   12.4   11.3    325
## pl   1.9   2.15  -0.076  5.000   14.5    7.9     86
## ng -19.3  -8.84  12.417 14.498  280.8  144.1   2989
## we  17.2  13.44  11.322  7.861  144.1  669.1   3278
## gy -85.8 138.00 324.727 86.158 2988.5 3277.6 145163
## 
## -----------------------------------------------------------------------------------
## Genotypic variance-covariance matrix
## -----------------------------------------------------------------------------------
##       ph     hf      pp     pl     ng     we     gy
## ph  38.0  23.48  -1.659  2.073  -17.6   17.4    -96
## hf  23.5  27.56  -0.440  2.054   -7.9   14.3    127
## pp  -1.7  -0.44   2.167 -0.069   11.8   11.2    328
## pl   2.1   2.05  -0.069  4.706   14.7    8.3     86
## ng -17.6  -7.90  11.850 14.725  261.1  142.3   3018
## we  17.4  14.31  11.160  8.274  142.3  658.7   3248
## gy -96.4 126.82 328.036 86.315 3018.1 3248.2 142152
coincidence_index(sel1 = sh$sel_gen, sel2 = mg$sel_gen, total = 22)
## [1] 69.5122