--- title: "Validation and the corrections of the earlier version" 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 the earlier version} %\VignetteEngine{quarto::html} %\VignetteEncoding{UTF-8} execute: echo: true warning: false message: false --- {{< include _stability-macros.txt >}} ```{r setup, include = FALSE} knitr::opts_chunk$set(collapse = FALSE, comment = "", fig.width = 7, fig.height = 4.6, dev = if (knitr::is_latex_output()) "cairo_pdf" else if (requireNamespace("svglite", quietly = TRUE)) "svglite" else "png") if (requireNamespace("stability", quietly = TRUE)) library(stability) else pkgload::load_all(export_all = FALSE, helpers = FALSE, quiet = TRUE) ``` # Abstract Every result is checked against an independent computation. This vignette shows the main checks and lists the corrections of the earlier version, each with its effect on `ge_data`. # Analyses of variance against lm() ```{r lm} aa <- add_anova( .data = ge_data , .y = Yield , .rep = Rep , .gen = Gen , .env = Env ) a2 <- anova(lm(formula = terms(Yield ~ Env + Env:Rep + Gen + Gen:Env, keep.order = TRUE), data = ge_data)) all.equal(target = aa$anova[["Sum Sq"]], current = a2[["Sum Sq"]]) ``` # Regression against lm() ```{r reg} reg <- stab_reg( .data = ge_data , .y = Yield , .rep = Rep , .gen = Gen , .env = Env ) M <- with(data = ge_data, expr = tapply(X = Yield, INDEX = list(Gen, Env), FUN = mean)) b <- vapply( X = reg$StabIndvReg$Gen , FUN = function(g) coef(lm(M[g, ] ~ colMeans(M)))[[2]] , FUN.VALUE = 0 ) all.equal(target = reg$StabIndvReg$Slope, current = unname(b)) ``` # Eskridge (1990), Table 4 Eskridge's Table 4 gives the four safety-first indices of 12 CIMMYT entries at $\alpha = 0.05$, computed from the summaries of his Table 3 (means, variances, slopes, Shukla's variances, deviation mean squares, with $S^2_y = 1.87$, $\hat{\sigma}^2_E = 1.80$ and $E = 15$). The package's core recomputes all 48 values from the same summaries: ```{r eskridge-ref} ref <- stab_reference( source = "Eskridge" , evaluate = TRUE , level = 1 ) tab <- ref[, list( quantity = sub(pattern = " \\(alpha.*", replacement = "", x = quantity) , published = value , computed = round(x = computed, digits = 3) , agrees )] tab sum(ref$agrees) max(abs(ref$computed - ref$value)[!grepl(pattern = "entry 8", x = ref$quantity)]) ``` Of the 48 values, `r sum(ref$agrees)` agree to the two printed decimals. The remaining ones differ by at most 0.02, because the summaries of Table 3 are printed to two decimals, with one exception. For entry 8, Table 3 prints the slope $b = 1.27$, the same as for entry 7; the published FW (4.17) and ER (3.55) of entry 8 both fit $b = 1.22$, so the printed slope appears to be a misprint. `stab_reference()` gives the reason for every difference in the column `note`. # Order of the rows The earlier version attached stability statistics to the wrong genotypes when the data were not sorted by genotype. The results no longer depend on the order of the rows: ```{r order} set.seed(seed = 1) shuffled <- ge_data[sample(x = nrow(ge_data)), ] k1 <- stab_kang( .data = ge_data , .y = Yield , .rep = Rep , .gen = Gen , .env = Env )$Kang k2 <- stab_kang( .data = shuffled , .y = Yield , .rep = Rep , .gen = Gen , .env = Env )$Kang all.equal(target = k1, current = k2) ``` # Corrections | Function | Earlier version | Now | |---|---|---| | `stab_kang`, `stab_asv`, `stab_masv`, `stab_dist`, `stab_reg`, AMMI1 plot | statistics attached to other genotypes unless the data were sorted by genotype | each statistic on its genotype | | `indiv_anova` | genotypes only in each environment | randomized complete blocks (replicates in the model) | | `er_anova` | Total and Gen from the replicate line; deviations divided by $B$; error df $EG(B-1)$ | Eberhart and Russell's lines; error df $E(G-1)(B-1)$ | | `stab_reg` | `Delta` = deviation SS divided by $B$ | `Delta` = $S^2_{d_i}$ with its test | | `stab_par` | parameters divided by $B$; error df $(G-1)^2E$; rating +2 at `alpha`; one-sided LSD; covariate per plot | scale of the means; error df $E(G-1)(B-1)$; rating $-2$; two-sided LSD; covariate per environment | | `stab_fox` | plots ranked and counted (up to 12 of 11 environments) | genotype means ranked in each environment | | `stab_asv` | $\lambda_1/\lambda_2$ on the squared score | $SS_1/SS_2$ on the score | | `stab_masv` | ratios of singular values | ratios of sums of squares | | `ammi` | an axis with a zero singular value | the axes that exist | # Summary The analyses of variance and the regressions agree with `lm()`; the stability statistics follow their published formulas and no longer depend on the order of the data. # References Eskridge, K. M. (1990). Selection of stable cultivars using a safety-first rule. *Crop Science*, 30(2), 369--374. Eberhart, S. A. and Russell, W. A. (1966). Stability parameters for comparing varieties. *Crop Science*, 6(1), 36--40. Purchase, J. L., Hatting, H. and van Deventer, C. S. (2000). Genotype x environment interaction of winter wheat in South Africa: II. Stability analysis of yield performance. *South African Journal of Plant and Soil*, 17(3), 101--107. Zali, H., Farshadfar, E., Sabaghpour, S. H. and Karimizadeh, R. (2012). Evaluation of genotype x environment interaction in chickpea using measures of stability from AMMI model. *Annals of Biological Research*, 3(7), 3126--3136. Fox, P. N., Skovmand, B., Thompson, B. K., Braun, H. J. and Cormier, R. (1990). Yield and adaptation of hexaploid spring triticale. *Euphytica*, 47(1), 57--64.