--- title: "Validation and the corrections of version 0.6.0" author: "Muhammad Yaseen" date: last-modified format: html: self-contained: true number-sections: true toc: true toc-depth: 3 highlight-style: pygments code-tools: true html-math-method: mathjax vignette: > %\VignetteIndexEntry{Validation and the corrections of version 0.6.0} %\VignetteEngine{quarto::html} %\VignetteEncoding{UTF-8} execute: echo: true warning: false message: false --- {{< include _DiallelAnalysisR-macros.txt >}} ```{r setup, include = FALSE} knitr::opts_chunk$set(collapse = FALSE, comment = "", fig.width = 7, fig.height = 4.2, dev = if (knitr::is_latex_output()) "cairo_pdf" else if (requireNamespace("svglite", quietly = TRUE)) "svglite" else "png") if (requireNamespace("DiallelAnalysisR", quietly = TRUE)) library(DiallelAnalysisR) else pkgload::load_all(export_all = FALSE, helpers = FALSE, quiet = TRUE) ``` # Abstract Every number the package computes is checked by its tests against an independent calculation. This vignette shows the main checks and lists the results that differ from version 0.6.0, with the reason for each change. # Closed forms against the exact decomposition The analyses use Griffing's closed forms. The package also contains the explicit least-squares projection of the cell means (`DiallelAnalysisR:::.da_griffing_decompose()`), used only to check them: ```{r closed} set.seed(seed = 1) check <- function(P, m) { M <- matrix(data = rnorm(n = P * P, mean = 50, sd = 10), nrow = P, ncol = P) if (m %in% c(2, 4)) M[lower.tri(M)] <- NA if (m %in% c(3, 4)) diag(M) <- NA cf <- DiallelAnalysisR:::.da_griffing_closed(M, m) ex <- DiallelAnalysisR:::.da_griffing_decompose(M, m) max(abs(c(cf$ss - ex$ss, cf$g - ex$g, cf$ems - ex$ems))) } outer(X = 5:9, Y = 1:4, FUN = Vectorize(check)) ``` The largest difference is of the order of rounding error for every number of parents and method. # Sums of squares against a linear model ```{r lm} p <- PartialDiallel( y = y , Rep = Rep , Cross1 = Cross1 , Cross2 = Cross2 , data = PartialDiallelData ) a <- anova(lm(formula = y ~ factor(Rep) + factor(Cross1) * factor(Cross2), data = PartialDiallelData)) cbind(package = p$ANOVA[c("GCA I", "GCA II", "SCA", "Error"), "Sum Sq"], lm = a[2:5, "Sum Sq"]) ``` # Results that changed The examples of every help page of version 0.6.0 were run with both versions; all results agree except these corrections: | Function | Result | Change | |---|---|---| | `Griffing()`, Model 1 | `StdErr` | standard errors use the error mean square; 0.6.0 used the replicate mean square | | `Griffing()`, Method 2 | `StdErr` | standard errors of $\hat{S}_{ii}$ and $\hat{S}_{ij}$ were swapped in 0.6.0 | | `Griffing()`, Method 4 | `StdErr` | the third value (a Method 1 formula) is `NA` | | `Griffing()`, Method 4 | `Means` | all parents in rows and columns (0.6.0: 7 x 7, misaligned labels) | | `Griffing()`, Model 2, Methods 1, 3 | `ANOVA` | p-value of the reciprocal line on the error degrees of freedom | | `Hayman()` | `ANOVA` | lines $b$, $b_3$, $d$ divide by 4 where 0.6.0 divided by the number of replicates (equal only with 4 replicates) | | `Hayman()` | components | $H_2 = 4V_{1L1} - 4V_{0L1} - 2E$ (0.6.0 added $4V_{0L1}$); $W_r$ and $V_r$ from the reciprocal-averaged table | | `Hayman()` | arguments | the column arguments are used (0.6.0 read `Cross1`, `Cross2` by name) | | `PartialDiallel()` | arguments | the column arguments are used (0.6.0 read `y`, `Rep`, `Cross1`, `Cross2` by name) | | `PartialDiallel()` | `ANOVA` | error line on the plot scale (0.6.0 divided it by the number of replicates, inflating every $F$) | | `PartialDiallel()` | components | variance components (0.6.0 gave differences of mean squares) | The size of the first correction for this data set: ```{r se-change} f <- Griffing( y = Yield , Rep = Rep , Cross1 = Cross1 , Cross2 = Cross2 , data = GriffingData1 , Method = 1 , Model = 1 , Reciprocal = c("combined", "split")[1] ) ms <- f$RCBD[c("Rep", "Residuals"), "Mean Sq"] round(x = cbind(`1.0.0` = f$StdErr, `0.6.0` = f$StdErr * sqrt(ms[1] / ms[2])), digits = 3) ``` # Published values: Griffing (1956) The checks above compare the package with exact computations. The numerical example of Griffing (1956) adds a comparison with the published tables: the means of 36 maize crosses in Table 6 (data set `Griffing56`), analysed with Method 4 from the table of means by `GriffingMeans()` with the error mean squares of Table 7 divided by the 78 plants of a cross mean. The file `reference.csv` of the package holds 77 values from Tables 8, 9, 10 and 13: mean squares, variance components and standard errors of Model I and Model II for total yield, cob weight and shelled corn. `da_reference()` recomputes each of them: ```{r published} ref <- da_reference( source = "Griffing" , evaluate = TRUE , level = 1 ) nrow(ref) table(ref$agrees) ``` The values that differ do so in the last printed digit, because Table 6 prints the means to one decimal place while Griffing worked from unrounded means: ```{r published-diff} ref <- as.data.frame(x = ref) d <- ref[!ref$agrees, c("quantity", "value", "computed")] d$difference <- round(x = d$computed - d$value, digits = 3) d$computed <- round(x = d$computed, digits = 2) d max(abs(d$difference)) ``` A few rows in full, for the total yield: ```{r published-show} x1 <- ref[grepl(pattern = "^X1", x = ref$quantity), c("quantity", "value", "computed")] x1$computed <- round(x = x1$computed, digits = 2) head(x = x1, n = 10) ``` Only Griffing's own tables are used: the values printed in a book can be compared in the same way by adding rows to `reference.csv` (a call, the expression that extracts the number, the printed value and its number of decimals). # Summary The analyses of variance, effects and components of version 0.6.0 are confirmed wherever they were right; the corrections above concern standard errors, three lines of Hayman's analysis with other than four replicates, two genetic components and the use of the column arguments. # References Griffing, B. (1956). Concept of general and specific combining ability in relation to diallel crossing systems. *Australian Journal of Biological Sciences*, 9(4), 463--493. Hayman, B. I. (1954). The theory and analysis of diallel crosses. *Genetics*, 39(6), 789--809. Hayman, B. I. (1954). The analysis of variance of diallel tables. *Biometrics*, 10(2), 235--244.