Skip to contents

sa_prompt() builds the text sent to an external text service (sa_ask()) for a written interpretation of one result of the package stability. It is specific to the method: it contains how the statistics of that method are read, what to concentrate on, the interpretation computed by stability::stab_interpret() (to be kept to), the facts behind it and the first rows of the main table.

Usage

sa_prompt(x, higher_better = TRUE, trait = NULL, rows = 15L)

Arguments

x

a result of a function of stability (or the ggplot of stability::gge_biplot()).

higher_better

TRUE (default) when larger values of the trait are better.

trait

name of the trait (default: the response of the analysis).

rows

number of rows of the main table included (default 15).

Value

A list with system and user (character strings) and interpretation (the result of stability::stab_interpret()).

Details

The text has two parts: system (the role and the rules: use only the numbers given, keep to the computed findings, name genotypes and environments as given, say when something cannot be concluded) and user (the material and the task: four sections, Statistical interpretation, Key agronomic findings, Recommendations and Next steps, at most about 350 words). Because the computed findings are part of the request, the written text cannot contradict the tests and rankings of the analysis without contradicting its own material, which the rules forbid.

See also

Author

Muhammad Yaseen (myaseen208@gmail.com)

Examples

fit <-
  stability::ammi(
      .data = stability::ge_data
    , .y    = Yield
    , .rep  = Rep
    , .gen  = Gen
    , .env  = Env
    )
p <-
  sa_prompt(
      x             = fit
    , higher_better = TRUE
    , trait         = "grain yield (kg/ha)"
    , rows          = 15
    )
cat(p$user)
#> Analysis: AMMI analysis (function ammi of the R package stability)
#> Trait: grain yield (kg/ha); higher values are better
#> Trial: 60 genotypes in 11 environments, 2 replicates; grand mean 4060.8
#> 
#> How this method is read:
#> AMMI: additive genotype and environment effects plus principal components of the interaction, each tested (Gollob's F). The number of significant axes chooses the model (AMMI1, AMMI2, ...). Scores near zero = stable; genotype and environment scores of the same sign = positive interaction.
#> 
#> Concentrate on: the number of significant interaction axes, the genotypes with small scores (stable) and the environments with the strongest interaction.
#> 
#> Computed findings (keep to them):
#> - AMMI8: 8 interaction axes are significant; the first two axes explain 20.1% and 17.3% of the interaction.
#> - The interaction is significant (p < 0.001).
#> - Genotypes with a mean above average and the smallest first-axis scores (stable): NIBGE GANDUM3, PR119, V14154, V14170, TWS12464, PR115, MSH3 and PR118.
#> - Environments with the strongest interaction (largest first-axis scores): Gujranwala, FSD and KSK; the weakest: FSDR, Sahiwal and Khanewal.
#> - Genotypes and environments with first-axis scores of the same sign interact positively (the genotype does better there than its mean predicts).
#> - The first two axes explain less than half of the interaction; biplots show it only partly.
#> 
#> Facts:
#> p_env: 1.995e-08
#> p_gen: 3.507e-72
#> p_gxe: 1.907e-51
#> ss_env: 263900000
#> ss_gen: 71660000
#> ss_gxe: 201300000
#> n_axes: 8
#> pct: 20.08, 17.31
#> model: AMMI8
#> stable_high: NIBGE GANDUM3, PR119, V14154, V14170, TWS12464, PR115, MSH3, PR118
#> most_interactive_env: Gujranwala, FSD, KSK
#> least_interactive_env: FSDR, Sahiwal, Khanewal
#> 
#> Main table (first 5 rows): Analysis of variance
#>     Source  Df    Sum Sq  Mean Sq F value    Pr(>F)
#>        Env  10 263900000 26390000  68.060 1.995e-08
#>   Rep(Env)  11   4266000   387800      NA        NA
#>        Gen  59  71660000  1215000  12.250 3.507e-72
#>    Gen:Env 590 201300000   341200   3.441 1.907e-51
#>  Residuals 649  64360000    99170      NA        NA
#> 
#> Task: write four sections with exactly these headings:
#> ## 1. Statistical interpretation
#> (3 to 4 sentences: what the tests and statistics of this method show)
#> ## 2. Key agronomic findings
#> (3 to 4 sentences: the genotypes and environments that matter, as this method sees them)
#> ## 3. Recommendations
#> (2 to 3 sentences for selection or variety recommendation)
#> ## 4. Next steps
#> (1 to 2 sentences: checks or further analyses)
#> At most 350 words.