| Title: | Design and Analysis of Agricultural Experiments |
|---|---|
| Description: | Plans and analyses agricultural experiments with classical designs: completely randomised, randomised complete blocks (also generalised), Latin, Graeco-Latin and Youden squares, balanced, cyclic, alpha (Patterson and Williams (1976) <doi:10.1093/biomet/63.1.83>) and lattice incomplete blocks, augmented designs, factorials, split-plots, strip-plots, split-split-plots and nested designs, with or without covariates. Each analysis of variance tests every term against its own error stratum, with Satterthwaite (1946) <doi:10.2307/3002019> degrees of freedom for pooled errors; least-squares means are separated with eleven multiple-comparison procedures, among them Dunnett (1955) <doi:10.1080/01621459.1955.10501294>, and compact letters, with simple effects, trends and contrasts. It checks the assumptions, offers transformations and rank-based alternatives, recovers inter-block information by restricted maximum likelihood (Patterson and Thompson (1971) <doi:10.1093/biomet/58.3.545>), randomises field layouts with field books and power calculations, draws publication figures and writes HTML reports. It also includes plant breeding analyses (additive main effects and multiplicative interaction, Gollob (1968) <doi:10.1007/BF02289676>; stability, Eberhart and Russell (1966) <doi:10.2135/cropsci1966.0011183X000600010011x>; line by tester; diallel, Griffing (1956) <doi:10.1071/BI9560463>; North Carolina designs) and plant pathology tools (area under the disease progress curve and stairs, Simko and Piepho (2012) <doi:10.1094/PHYTO-07-11-0216>; soil heterogeneity). Only base R is used. |
| Authors: | Luis Ángel Barrera-Guzmán [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-8057-2583>) |
| Maintainer: | Luis Ángel Barrera-Guzmán <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0.0 |
| Built: | 2026-12-03 20:12:09 UTC |
| Source: | https://github.com/cran/AgriDesign |
residuals(), fitted(), nobs() and anova() work on the result of
design_anova() as on a linear model. anova() returns the analysis of
variance as a data frame of class "anova", with the error stratum
against which each term is tested. as.data.frame() on the result of
compare_means() returns its table of means with their letters.
## S3 method for class 'ad_anova' residuals(object, type = c("response", "studentized"), ...) ## S3 method for class 'ad_anova' fitted(object, ...) ## S3 method for class 'ad_anova' nobs(object, ...) ## S3 method for class 'ad_anova' anova(object, ...) ## S3 method for class 'ad_comparison' as.data.frame(x, row.names = NULL, optional = FALSE, ...)## S3 method for class 'ad_anova' residuals(object, type = c("response", "studentized"), ...) ## S3 method for class 'ad_anova' fitted(object, ...) ## S3 method for class 'ad_anova' nobs(object, ...) ## S3 method for class 'ad_anova' anova(object, ...) ## S3 method for class 'ad_comparison' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
object, x
|
A fitted design from |
type |
For |
row.names, optional, ...
|
Passed on or not used. |
A numeric vector (residuals, fitted values), a count (nobs), or a
data frame.
fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") anova(fit) head(residuals(fit, type = "studentized")) nobs(fit) as.data.frame(compare_means(fit, "Nitrogen_kg_ha"))fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") anova(fit) head(residuals(fit, type = "studentized")) nobs(fit) as.data.frame(compare_means(fit, "Nitrogen_kg_ha"))
The categorical palette used by the figures of the package (forest green,
ochre, blue, brick red, plum...), recycled to n colours.
agri_colors(n)agri_colors(n)
n |
Number of colours. |
A character vector of colours.
agri_colors(4)agri_colors(4)
Additive main effects and multiplicative interaction model (Gollob 1968; Gauch 1988): the analysis of variance of genotypes and environments, and the singular value decomposition of the genotype x environment interaction into principal axes (IPCA), each tested with the degrees of freedom of Gollob (1968).
ammi( data, response, genotype, environment, block = NULL, mse = NULL, df_error = NULL, reps = 1, n_axes = NULL )ammi( data, response, genotype, environment, block = NULL, mse = NULL, df_error = NULL, reps = 1, n_axes = NULL )
data |
A data frame in long format. |
response |
Name of the numeric response column. |
genotype, environment
|
Names of the genotype and environment columns. |
block |
Optional name of the block (replicate) column; blocks are taken as nested within environments. |
mse, df_error
|
Error mean square (plot scale) and its degrees of freedom, only when the data hold one mean per cell. |
reps |
Number of replicates behind each mean, when the data hold one mean per cell. |
n_axes |
Number of interaction axes shown in the analysis of variance (the rest is pooled as the residual interaction); by default all of them. |
The data must be balanced: every genotype in every environment with the
same number of replicates. With plot data the error comes from the trial
itself (with block, blocks within environments are taken out and
environments are tested against them). With one mean per cell, give the
pooled error of the trial (mse, on the plot scale, with df_error) and
the number of replicates behind each mean (reps).
Interaction scores are scaled by the square root of the singular values
(symmetric scaling), so that the product of a genotype score and an
environment score is their interaction. The sign of every axis is fixed so
that the environment with the largest absolute score is positive.
The AMMI stability value (ASV) of Purchase et al. (2000) is
sqrt((SS1 / SS2 * IPCA1)^2 + IPCA2^2); the yield stability index (YSI)
adds its rank to the rank of the mean (highest mean = 1).
An object of class "ad_ammi": the analysis of variance
(anova), the interaction axes (axes: singular value, sum of
squares, percentage of the interaction, Gollob degrees of freedom and F
test), genotype and environment means with their scores (genotypes,
environments, the first with ASV and YSI), the table of means and the
interaction residuals.
Gollob, H. F. (1968) Psychometrika 33, 73-115. Gauch, H. G. (1988) Biometrics 44, 705-715. Purchase, J. L., Hatting, H. and van Deventer, C. S. (2000) South African Journal of Plant and Soil 17, 101-107.
fit <- ammi(maize_met, "Yield_t_ha", "Hybrid", "Environment", block = "Block") fit plot(fit) plot(fit, type = "ammi2")fit <- ammi(maize_met, "Yield_t_ha", "Hybrid", "Environment", block = "Block") fit plot(fit) plot(fit, type = "ammi2")
audpc() integrates the disease progress curve with trapezoids (Shaner
and Finney 1977); audps() gives the area under the disease progress
stairs of Simko and Piepho (2012), which weighs the first and the last
assessment as much as the others: AUDPS = AUDPC + (y1 + yn) / 2 * D / (n - 1), with D the time from the first to the last assessment.
audpc( evaluation, dates, type = c("absolute", "relative", "standardized"), ymax = 100 ) audps( evaluation, dates, type = c("absolute", "relative", "standardized"), ymax = 100 )audpc( evaluation, dates, type = c("absolute", "relative", "standardized"), ymax = 100 ) audps( evaluation, dates, type = c("absolute", "relative", "standardized"), ymax = 100 )
evaluation |
Disease intensities: a vector (one unit) or a matrix or data frame with one row per unit and one column per assessment. |
dates |
Times of the assessments (days or Date values), strictly increasing. |
type |
|
ymax |
Largest possible intensity (100 for percentages, 1 for proportions, the top of a rating scale). |
type = "relative" divides the area by the largest possible one, so it
lies between 0 and 1: ymax * D for the AUDPC and ymax * D * n / (n - 1)
for the AUDPS, whose stairs are n / (n - 1) times as wide as the curve.
type = "standardized" divides by the width only and gives the mean
intensity over the epidemic, in the units of the assessments.
Missing assessments of a unit are skipped (its area then spans its own
assessments only).
A numeric vector with one area per unit.
Shaner, G. and Finney, R. E. (1977). The effect of nitrogen fertilization on the expression of slow-mildewing resistance in Knox wheat. Phytopathology 67, 1051-1056.
Simko, I. and Piepho, H.-P. (2012). The area under the disease progress stairs: calculation, advantage, and application. Phytopathology 102, 381-389.
audpc_by_unit() to compute them for every plot of a trial.
days <- c(7, 14, 21, 28, 35) sev <- c(1, 4, 12, 30, 52) audpc(sev, days) audps(sev, days) audpc(sev, days, type = "relative") audps(rbind(plot1 = sev, plot2 = sev / 2), days, type = "standardized")days <- c(7, 14, 21, 28, 35) sev <- c(1, 4, 12, 30, 52) audpc(sev, days) audps(sev, days) audpc(sev, days, type = "relative") audps(rbind(plot1 = sev, plot2 = sev / 2), days, type = "standardized")
Takes the assessments in long format (one row per plot and date), sorts
them by time within each plot and returns one row per plot with its areas,
ready for design_anova().
audpc_by_unit(data, response, time, units, ymax = 100)audpc_by_unit(data, response, time, units, ymax = 100)
data |
A data frame in long format. |
response |
Column with the disease intensity. |
time |
Column with the time of assessment (numbers or Date). |
units |
Column(s) that identify a plot, for instance
|
ymax |
Largest possible intensity (100 for percentages, 1 for proportions, the top of a rating scale). |
A data frame with the unit columns, the number of assessments
(n), the time spanned (duration) and the areas audpc, audps,
their relative (audpc_rel, audps_rel) and standardised (audpc_std,
audps_std) forms.
a <- audpc_by_unit(blight_progress, "Severity_pct", "Day", c("Block", "Treatment")) head(a) fit <- design_anova(a, "audps", "Treatment", block = "Block") compare_means(fit, "Treatment")a <- audpc_by_unit(blight_progress, "Severity_pct", "Day", c("Block", "Treatment")) head(a) fit <- design_anova(a, "audps", "Treatment", block = "Block") compare_means(fit, "Treatment")
Completely randomised design with five common bean varieties.
bean_varietiesbean_varieties
A data frame with 20 rows and 3 columns:
Plot number.
Bean variety.
Yield, kg per plot.
design_anova(bean_varieties, "Yield_kg_plot", "Variety")design_anova(bean_varieties, "Yield_kg_plot", "Variety")
Simulated grain yields of seven sorghum hybrids in seven blocks of three plots: every hybrid appears three times and every pair of hybrids meets once in a block (t = 7, k = 3, r = 3, lambda = 1).
bib_sorghumbib_sorghum
A data frame with 21 rows and 3 columns:
Block (1-7).
Hybrid (H1-H7).
Grain yield, t/ha.
durbin_test(bib_sorghum, "Yield_t_ha", "Hybrid", "Block")durbin_test(bib_sorghum, "Yield_t_ha", "Hybrid", "Block")
Simulated severity of late blight (percentage of leaf area affected) in a potato trial with four fungicide programmes in four blocks, assessed weekly from day 21 to day 63 after planting. The values were generated with logistic epidemics (data-raw/make-data-pathology.R).
blight_progressblight_progress
A data frame with 112 rows and 4 columns:
Block (1-4).
Fungicide programme: Untreated, Contact, Systemic, Alternated.
Days after planting.
Disease severity, percent.
a <- audpc_by_unit(blight_progress, "Severity_pct", "Day", c("Block", "Treatment")) design_anova(a, "audpc", "Treatment", block = "Block")a <- audpc_by_unit(blight_progress, "Severity_pct", "Day", c("Block", "Treatment")) design_anova(a, "audpc", "Treatment", block = "Block")
Profile log-likelihood of the Box-Cox power lambda for the model of the
design, its maximum, the 95 % interval and the nearest conventional power
(-1, -0.5, 0, 0.5, 1 or 2).
box_cox(fit, lambda = seq(-2, 2, by = 0.1))box_cox(fit, lambda = seq(-2, 2, by = 0.1))
fit |
An |
lambda |
Grid of powers. |
A list with the profile (profile), the estimate (lambda), the
95 % interval (lower, upper), the nearest conventional power
(rounded) and whether the interval contains 1 (contains_one); NULL
when the response has zeros or negative values.
fit <- design_anova(tomato_factorial, "Yield_kg_plant", c("Variety", "Fertilizer"), block = "Block") box_cox(fit)[c("lambda", "lower", "upper", "rounded")]fit <- design_anova(tomato_factorial, "Yield_kg_plant", c("Variety", "Fertilizer"), block = "Block") box_cox(fit)[c("lambda", "lower", "upper", "rounded")]
Runs the usual checks on the residuals of a fitted design: normality (Shapiro-Wilk, Anderson-Darling, Jarque-Bera), homogeneity of variances among treatments (Levene with median and with mean, Bartlett, Fligner-Killeen, Hartley's Fmax), additivity of blocks and treatments (Tukey's one-degree-of-freedom test, only for blocked designs), independence in data order (Durbin-Watson) and extreme studentized residuals. The checks are summarised in a grade from A (assumptions satisfied) to D (several assumptions fail).
check_assumptions(fit, alpha = 0.05)check_assumptions(fit, alpha = 0.05)
fit |
An |
alpha |
Significance level of the checks. |
Each check is rated "ok" when its p-value is at least alpha, "warn"
when it lies between alpha / 5 and alpha and "bad" below alpha / 5.
The grade is D with two or more "bad" checks, C with one "bad" or two
"warn", B with a single "warn" and A otherwise.
An object of class "ad_assumptions" with the table of tests
(tests), the residuals and studentized residuals (residuals), the
observations with |studentized residual| > 2.5 (suspicious) and the
grade.
fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") check_assumptions(fit)fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") check_assumptions(fit)
Separates the least-squares means of a treatment factor (or of the combinations of two factors) with one of eleven procedures and labels them with letters: levels that share a letter do not differ. Each factor is compared with its own error stratum (for instance, main plots of a split-plot with Error a).
compare_means( fit, factor, method = "tukey", alpha = 0.05, control = NULL, by = NULL )compare_means( fit, factor, method = "tukey", alpha = 0.05, control = NULL, by = NULL )
fit |
An |
factor |
Treatment factor whose means are compared; two names compare
all their combinations together (not available for split- or
strip-plots, where |
method |
Procedure, see Details. |
alpha |
Significance level. |
control |
Level used as control by Dunnett's test (default: first level). |
by |
Optional second treatment factor: compare |
Methods: "tukey" (Tukey-Kramer HSD), "lsd" (Fisher), "bonferroni",
"sidak", "holm", "duncan", "snk" (Student-Newman-Keuls),
"regwq", "scheffe", "dunnett" (each level against control; the
groups are then "*" for a difference with the control and "ns") and
"games_howell" (unequal variances; own SE and Welch df per pair).
With by, the comparison is made within each level of another factor
(simple effects). In split-plots the sub-plot factor within a main plot
uses Error b, and the main-plot factor within a sub-plot level uses the
pooled error [(b - 1) Eb + Ea] / b with Satterthwaite degrees of
freedom; strip-plots pool their errors the same way.
An object of class "ad_comparison" with the means and their
letters (means), the pairwise comparisons (pairs), the minimum
significant difference (msd, for equal replication) and the error used.
fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") compare_means(fit, "Nitrogen_kg_ha") fit <- design_anova(bean_varieties, "Yield_kg_plot", "Variety") compare_means(fit, "Variety", method = "dunnett", control = "Negro Jamapa") fit <- design_anova(split_irrigation, "Yield_t_ha", c("Irrigation", "Variety"), block = "Block", design = "split_rcbd") compare_means(fit, "Variety", by = "Irrigation")fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") compare_means(fit, "Nitrogen_kg_ha") fit <- design_anova(bean_varieties, "Yield_kg_plot", "Variety") compare_means(fit, "Variety", method = "dunnett", control = "Negro Jamapa") fit <- design_anova(split_irrigation, "Yield_t_ha", c("Irrigation", "Variety"), block = "Block", design = "split_rcbd") compare_means(fit, "Variety", by = "Irrigation")
Fits the linear model of a classical agricultural design and tests every term against the right error stratum (for instance, main plots of a split-plot against Error a).
design_anova( data, response, treatment, block = NULL, row = NULL, col = NULL, covariate = NULL, design = NULL, ss_type = 3, random_blocks = TRUE, random_nested = TRUE, transform = NULL )design_anova( data, response, treatment, block = NULL, row = NULL, col = NULL, covariate = NULL, design = NULL, ss_type = 3, random_blocks = TRUE, random_nested = TRUE, transform = NULL )
data |
A data frame in long format: one row per plot. |
response |
Name of the numeric response column. |
treatment |
Name(s) of the treatment factor(s). In split-plots, strip-plots and nested designs the order matters: the first factor goes on main plots (or is the outer factor). |
block |
Name of the block column; two names (replicate, block within replicate) for incomplete block designs. |
row, col
|
Names of the row and column factors of a Latin square. |
covariate |
Name(s) of numeric covariates (analysis of covariance). |
design |
Identifier of the design (see |
ss_type |
Type of sums of squares: |
random_blocks |
In a generalised RCBD, treat blocks as random and test treatments against the block x treatment interaction. |
random_nested |
In a nested design, treat the inner factor as random and test the outer factor against it. |
transform |
Optional transformation of the response before the
analysis, by its identifier in |
An object of class "ad_anova": a list with the ANOVA table
(table), the error strata (strata), the grand mean, the coefficient
of variation, R squared, the fitted model and the data used.
fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block", design = "rcbd") fit design_anova(split_irrigation, "Yield_t_ha", c("Irrigation", "Variety"), block = "Block", design = "split_rcbd")fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block", design = "rcbd") fit design_anova(split_irrigation, "Yield_t_ha", c("Irrigation", "Variety"), block = "Block", design = "split_rcbd")
The efficiency factor of a block design is the harmonic mean of its canonical efficiency factors: the average variance of a treatment difference in a complete block design with the same replication, divided by the average variance in this design (intra-block analysis, same error variance). It is 1 for complete blocks and the target of incomplete block designs. For resolvable designs the upper bound of Patterson and Williams (1976) is also reported.
design_efficiency(x, treatment = "Treatment", block = NULL)design_efficiency(x, treatment = "Treatment", block = NULL)
x |
An |
treatment, block
|
Column names of the treatment and of the
(incomplete) block when |
A list with the efficiency factor E, the canonical efficiency
factors, whether the design is connected, and upper_bound for
equireplicated resolvable designs.
lay <- make_design("alpha", trt = 12, r = 2, k = 3, seed = 1) design_efficiency(lay)$Elay <- make_design("alpha", trt = 12, r = 2, k = 3, seed = 1) design_efficiency(lay)$E
Builds a self-contained HTML report of a fitted design: a materials and methods paragraph ready to adapt, descriptive statistics, the assumption checks with their grade, the analysis of variance with a draft of the results, the means with their letters, trend analysis of quantitative factors, simple effects of two-factor interactions, figures embedded as vector graphics, appendices with the pairwise comparisons and the data, and how to cite the software. Open it in any web browser and print it to PDF from there (A4 page style included).
design_report( fit, file = NULL, title = NULL, authors = "", affiliation = "", trial = "", objective = "", units = "", method = "tukey", alpha = 0.05, control = NULL, assumptions = TRUE, figures = TRUE, pairwise = TRUE, data = FALSE, cite = TRUE, open = FALSE )design_report( fit, file = NULL, title = NULL, authors = "", affiliation = "", trial = "", objective = "", units = "", method = "tukey", alpha = 0.05, control = NULL, assumptions = TRUE, figures = TRUE, pairwise = TRUE, data = FALSE, cite = TRUE, open = FALSE )
fit |
An |
file |
Output file ( |
title, authors, affiliation, trial, objective
|
Texts for the head of the report. |
units |
Units of the response, for the methods paragraph. |
method, alpha
|
Mean-separation procedure and significance level (see |
control |
Control level for |
assumptions, figures, pairwise, data, cite
|
Include those sections. |
open |
Open the report in the browser when it is written. |
The HTML text, invisibly.
fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") f <- tempfile(fileext = ".html") design_report(fit, f, title = "Nitrogen rates in maize", units = "t/ha", figures = FALSE) file.exists(f)fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") f <- tempfile(fileext = ".html") design_report(fit, f, title = "Nitrogen rates in maize", units = "t/ha", figures = FALSE) file.exists(f)
designs() lists the 16 designs that design_anova() analyses;
designs("layout") lists the 16 designs that make_design() randomises,
with the arguments each one needs and the design to give to
design_anova() once the responses are in the field book.
designs(type = c("analysis", "layout"))designs(type = c("analysis", "layout"))
type |
|
Designs analysed by design_anova() (design =):
| id | Design | Roles |
crd |
Completely randomised | treatment |
rcbd |
Randomised complete blocks | treatment, block |
grcbd |
Generalised RCBD (replicates within blocks) | treatment, block |
latin |
Latin square | treatment, row, col |
graeco |
Graeco-Latin square | treatment, row, col, block (Greek letters) |
youden |
Youden square | treatment, row, col |
bib |
Incomplete blocks (BIBD, cyclic) | treatment, block |
ibd |
Resolvable incomplete blocks (lattice, alpha) | treatment, block = c(rep, block) |
augmented |
Augmented (checks and new entries) | treatment, block |
fact_crd |
Factorial in CRD (2 to 4 factors) | treatment = c(A, B, ...) |
fact_rcbd |
Factorial in RCBD (2 to 4 factors) | treatment = c(A, B, ...), block |
split_rcbd |
Split-plot in RCBD | treatment = c(main, sub), block |
split_crd |
Split-plot in CRD | treatment = c(main, sub), block (replicate) |
strip_rcbd |
Strip-plot (split-block) | treatment = c(A, B), block |
splitsplit_rcbd |
Split-split-plot in RCBD | treatment = c(main, sub, sub-sub), block |
nested |
Nested (hierarchical) | treatment = c(outer, inner) |
Designs randomised by make_design() (first argument; C is optional in
factorials, and the conditions on the number of treatments and the block
size are in the conditions column of designs("layout")):
| id | Design | Arguments | Analyse as |
crd |
Completely randomised | trt, r |
crd |
rcbd |
Randomised complete blocks | trt, r |
rcbd |
latin |
Latin square | trt |
latin |
graeco |
Graeco-Latin square | trt, greek |
graeco |
youden |
Youden square | trt, k |
youden |
bib |
Balanced incomplete blocks | trt, k |
bib |
cyclic |
Cyclic incomplete blocks | trt, k, r |
bib |
ibd |
Resolvable incomplete blocks | trt, k, r |
ibd |
alpha |
Alpha design | trt, k, r |
ibd |
lattice |
Square lattice | trt, k, r |
ibd |
augmented |
Augmented | checks, entries, r |
augmented |
fact_crd |
Factorial in CRD | A, B, C, r |
fact_crd |
fact_rcbd |
Factorial in RCBD | A, B, C, r |
fact_rcbd |
split_rcbd |
Split-plot in RCBD | A, B, r |
split_rcbd |
strip |
Strip-plot | A, B, r |
strip_rcbd |
splitsplit |
Split-split-plot | A, B, C, r |
splitsplit_rcbd
|
A data frame. For "analysis": the identifier of each design (the
value to pass to design = in design_anova()), its name, the number of
treatment factors and block columns, and whether it needs rows and
columns. For "layout": the identifier (the first argument of
make_design()), its name, the arguments it needs (in parentheses when
optional), its conditions and the design of design_anova() that
analyses its field book.
designs() designs("layout") # the layout reports the call that analyses it make_design("strip", A = c("Drip", "Furrow"), B = c("V1", "V2", "V3"), r = 3, seed = 1)$analysisdesigns() designs("layout") # the layout reports the call that analyses it make_design("strip", A = c("Drip", "Furrow"), B = c("V1", "V2", "V3"), r = 3, seed = 1)$analysis
Griffing's (1956) analysis of a diallel cross by any of the four methods: 1, parents, F1 and reciprocals; 2, parents and one F1 per pair; 3, F1 and reciprocals; 4, one F1 per pair. The analysis of variance of general (GCA) and specific (SCA) combining ability, and of reciprocal effects (split into maternal and non-maternal, Cockerham 1963) in methods 1 and 3; the effects with their exact standard errors (Model I), the standard errors of differences, and the variance components of Model II with the additive and dominance variances.
diallel( data, response, parent1, parent2, block = NULL, method = 1, inbreeding = 1 )diallel( data, response, parent1, parent2, block = NULL, method = 1, inbreeding = 1 )
data |
A data frame in long format. |
response |
Name of the numeric response column. |
parent1, parent2
|
Names of the female and male parent columns (equal for the parents themselves). |
block |
Name of the block column (randomised complete blocks); when
|
method |
Griffing's method, 1 to 4. |
inbreeding |
Inbreeding coefficient of the parents, used to turn the Model II components into additive and dominance variances (1 for inbred lines). |
The combining-ability analysis is on the scale of entry means: the error is the error mean square of the trial divided by the number of replicates. Rows that do not belong to the method are left out (parents in methods 3 and 4; reciprocals in methods 2 and 4, where the cross with the first parent as female is kept), so one data set serves all methods. The effects are the least-squares estimates under Griffing's restrictions (sum of GCA effects zero; SCA effects summing to zero for every parent, the selfs counted twice in method 2), which reproduce his closed formulas.
An object of class "ad_diallel".
Griffing, B. (1956) Australian Journal of Biological Sciences 9, 463-493. Cockerham, C. C. (1963) In Statistical Genetics and Plant Breeding, NAS-NRC 982, 53-94.
dl <- diallel(maize_diallel, "Yield_t_ha", "Female", "Male", block = "Block", method = 1) dl diallel(maize_diallel, "Yield_t_ha", "Female", "Male", block = "Block", method = 4)$gcadl <- diallel(maize_diallel, "Yield_t_ha", "Female", "Male", block = "Block", method = 1) dl diallel(maize_diallel, "Yield_t_ha", "Female", "Male", block = "Block", method = 4)$gca
Ordinal severity scores (0-9) of a foliar disease under four fungicide treatments in five blocks; suited to the rank-based (Friedman) analysis.
disease_scoresdisease_scores
A data frame with 20 rows and 3 columns:
Block (1-5).
Fungicide treatment, including an untreated control.
Disease severity score.
Rank-based comparison of treatments in a balanced incomplete block design
(every block has k of the t treatments, every treatment appears r
times): the observations are ranked within each block and the rank sums
are compared (Durbin 1951). With complete blocks it is Friedman's test.
Pairwise comparisons use Conover's t test on the rank sums with
b k - b - t + 1 degrees of freedom; ties get average ranks.
durbin_test( x, response = NULL, treatment = NULL, block = NULL, alpha = 0.05, p_adjust = "holm" )durbin_test( x, response = NULL, treatment = NULL, block = NULL, alpha = 0.05, p_adjust = "holm" )
x |
An |
response, treatment, block
|
Column names when |
alpha |
Significance level of the pairwise comparisons. |
p_adjust |
Adjustment of the pairwise p-values, as in
|
An object of class c("ad_durbin", "ad_nonparametric") with the
test (chi-square and its F form), the pairwise comparisons, the groups
with their rank sums and letters, the design parameters (design) and
the least significant difference of rank sums (lsd_ranks).
Durbin, J. (1951). Incomplete blocks in ranking experiments. British Journal of Statistical Psychology 4, 85-90.
Conover, W. J. (1999). Practical Nonparametric Statistics, 3rd ed. Wiley, New York, section 5.9.
durbin_test(bib_sorghum, "Yield_t_ha", "Hybrid", "Block")durbin_test(bib_sorghum, "Yield_t_ha", "Hybrid", "Block")
The field book of make_design() with empty columns for the responses to
be measured, ready to be filled in and analysed with design_anova().
field_book(layout, responses = "Response", file = NULL)field_book(layout, responses = "Response", file = NULL)
layout |
An |
responses |
Names of the response columns to add. |
file |
Optional CSV file to write. |
The field book as a data frame (invisibly when file is given).
lay <- make_design("rcbd", trt = 4, r = 3, seed = 7) head(field_book(lay, c("Yield", "Height")))lay <- make_design("rcbd", trt = 4, r = 3, seed = 7) head(field_book(lay, c("Yield", "Height")))
Hatheway's (1961) relation between plot size, replication and the
difference that can be detected, from Smith's index:
x^b = 2 (t1 + t2)^2 CV1^2 / (r d^2), where CV1 is the coefficient of
variation of the basic units (%), d the true difference to detect as a
percentage of the mean, r the number of replicates, t1 the two-sided
t for alpha and t2 the one-sided t for the power wanted.
hatheway_size( index, reps, difference, alpha = 0.05, power = 0.8, treatments = NULL, cv = NULL )hatheway_size( index, reps, difference, alpha = 0.05, power = 0.8, treatments = NULL, cv = NULL )
index |
An |
reps |
Number(s) of replicates. |
difference |
Difference(s) to detect, as a percentage of the mean. |
alpha |
Significance level (two-sided). |
power |
Probability of detecting the difference. |
treatments |
Optional number of treatments: the t values then use
the error degrees of freedom of a randomised complete block design,
|
cv |
Coefficient of variation (%) of the basic units; by default the one of the uniformity trial. |
A data frame with reps, difference, the error df and the
plot size in basic units (plot_size).
Hatheway, W. H. (1961). Convenient plot size. Agronomy Journal 53, 279-280.
sm <- smith_index(uniformity_trial) hatheway_size(sm, reps = 3:6, difference = c(10, 15), treatments = 8)sm <- smith_index(uniformity_trial) hatheway_size(sm, reps = 3:6, difference = c(10, 15), treatments = 8)
Analysis of a line x tester mating design (Kempthorne 1957; Singh and Chaudhary 1985): the analysis of variance of the entries in randomised complete blocks, with the crosses partitioned into lines, testers and their interaction; general combining ability of lines and testers, specific combining ability of the crosses, their standard errors, the proportional contribution of every source to the variation among crosses and the genetic components.
line_tester(data, response, line, tester, block = NULL)line_tester(data, response, line, tester, block = NULL)
data |
A data frame in long format. |
response |
Name of the numeric response column. |
line, tester
|
Names of the line (female) and tester (male) columns. |
block |
Name of the block column (randomised complete blocks); when
|
A row is a cross when it has both a line and a tester, a line parent when
the tester is missing (NA or empty) and a tester parent when the line is
missing; parents are optional. Rows with neither (for instance checks) are
not used.
Lines and testers are tested against the error and, in the random model
of Kempthorne, against the line x tester interaction (anova_lxt). The
average covariance of half sibs is
[((l-1) MSl + (t-1) MSt) / (l+t-2) - MSlxt] (l+t-2) / (r (2lt - l - t)),
the moment estimator under equal variances of lines and testers;
sigma2_A = 4 CovHS / (1 + F) and sigma2_D = 4 sigma2_SCA / (1 + F)^2
are given for F = 0 and F = 1. The standard errors of the effects are
the usual ones, sqrt(MSE / (r t)) for lines, sqrt(MSE / (r l)) for
testers and sqrt(MSE / r) for crosses.
An object of class "ad_line_tester".
Kempthorne, O. (1957) An Introduction to Genetic Statistics. Wiley. Singh, R. K. and Chaudhary, B. D. (1985) Biometrical Methods in Quantitative Genetic Analysis. Kalyani.
lt <- line_tester(maize_lxt, "Yield_t_ha", "Line", "Tester", block = "Block") ltlt <- line_tester(maize_lxt, "Yield_t_ha", "Line", "Tester", block = "Block") lt
Means of the levels of one or more factors, adjusted for the other terms of the model: the other factors get equal weights and covariates are held at their mean.
ls_means(fit, factors)ls_means(fit, factors)
fit |
An |
factors |
Name(s) of the factor(s) whose means are wanted. |
A data frame with one row per level (or combination of levels): the least-squares mean, its standard error, the number of observations and the raw mean and standard deviation.
fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block", design = "rcbd") ls_means(fit, "Nitrogen_kg_ha")fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block", design = "rcbd") ls_means(fit, "Nitrogen_kg_ha")
Simulated yields of a complete diallel (Griffing's method 1: parents, F1 and reciprocals) among six inbred lines, in three randomised complete blocks. The other methods use subsets of the same data.
maize_diallelmaize_diallel
A data frame with 108 rows and 4 columns:
Block (1-3).
Female parent (P1-P6).
Male parent (P1-P6); equal to Female for the parents.
Grain yield, t/ha.
diallel(maize_diallel, "Yield_t_ha", "Female", "Male", block = "Block", method = 2)diallel(maize_diallel, "Yield_t_ha", "Female", "Male", block = "Block", method = 2)
Simulated yields of six lines crossed with three testers, evaluated with the nine parents in three randomised complete blocks. Parents have an empty tester (lines) or an empty line (testers).
maize_lxtmaize_lxt
A data frame with 81 rows and 4 columns:
Block (1-3).
Line (L1-L6), NA for the tester parents.
Tester (T1-T3), NA for the line parents.
Grain yield, t/ha.
line_tester(maize_lxt, "Yield_t_ha", "Line", "Tester", block = "Block")line_tester(maize_lxt, "Yield_t_ha", "Line", "Tester", block = "Block")
Simulated yields of 12 maize hybrids in six environments, each a randomised complete block design with three blocks; the interaction has a multiplicative structure of rank two plus noise.
maize_metmaize_met
A data frame with 216 rows and 4 columns:
Environment (E1-E6).
Block within environment (1-3).
Hybrid (H01-H12).
Grain yield, t/ha.
ammi(maize_met, "Yield_t_ha", "Hybrid", "Environment", block = "Block")ammi(maize_met, "Yield_t_ha", "Hybrid", "Environment", block = "Block")
Randomised complete block design with four nitrogen rates in four blocks.
maize_nitrogenmaize_nitrogen
A data frame with 16 rows and 3 columns:
Block (1-4).
Nitrogen rate, kg/ha (0, 60, 120, 180).
Grain yield, t/ha.
design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block")design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block")
The same trial as maize_nitrogen, with one column per nitrogen rate. It shows the wide layout that has to be reshaped to long format (one row per plot) before the analysis.
maize_widemaize_wide
A data frame with 4 rows and 5 columns: Block and the yields
(t/ha) at N0, N60, N120 and N180.
Generates the randomised layout of a classical design, numbers the plots
and returns the field book (one row per plot) with the skeleton analysis
of variance. The randomisation is reproducible with seed and does not
change the random state of the session.
make_design( design = names(.generated), trt = NULL, r = 3, A = NULL, B = NULL, C = NULL, k = NULL, checks = NULL, entries = NULL, greek = NULL, seed = NULL, serpentine = TRUE, numbering = c("sequential", "block"), arrangement = c("stacked", "side"), blocks_per_row = 2, plots_per_row = NULL, gap = FALSE )make_design( design = names(.generated), trt = NULL, r = 3, A = NULL, B = NULL, C = NULL, k = NULL, checks = NULL, entries = NULL, greek = NULL, seed = NULL, serpentine = TRUE, numbering = c("sequential", "block"), arrangement = c("stacked", "side"), blocks_per_row = 2, plots_per_row = NULL, gap = FALSE )
design |
Design identifier: one of |
trt |
Treatment names, or a single number of treatments (named T1, T2...). |
r |
Number of replicates (blocks). |
A, B, C
|
Levels of the factors of factorial and split designs. |
k |
Block size of incomplete block designs. |
checks, entries
|
Checks and new entries of an augmented design. |
greek |
Levels of the second blocking factor of a Graeco-Latin square. |
seed |
Seed of the randomisation; |
serpentine |
Number the plots in serpentine order (back and forth along the field rows). |
numbering |
|
arrangement |
Blocks |
blocks_per_row |
Blocks per row of the field with |
plots_per_row |
Plots per row within a block (CRD, RCBD, factorials, augmented); by default a whole block in one row. |
gap |
Leave an empty row or column between blocks. |
The table of the designs, with the arguments each one needs and the
design of design_anova() that analyses its field book, is in
designs(); designs("layout") returns it as a data frame. Printing
the layout shows the call that analyses it (also in $analysis).
Designs: "crd", "rcbd", "latin" (as many rows and columns as
treatments), "fact_crd" and "fact_rcbd" (all combinations of A,
B and optionally C), "split_rcbd" (A on main plots, B on
sub-plots), "strip" (A in horizontal and B in vertical strips),
"splitsplit" (A, B, C), "ibd" (each replicate split at random
into blocks of k plots; the number of treatments must be a multiple of
k) and "augmented" (checks in every block and each of the
entries once).
Further designs: "graeco" (Graeco-Latin square: rows, columns, a
second blocking factor greek and the treatments, for an odd number of
treatments or 4 or 8), "youden" (incomplete Latin square: k rows and
as many columns as treatments, from a cyclic difference set), "bib"
(balanced incomplete blocks of size k: cyclic when a difference set is
known, otherwise all combinations), "cyclic" (incomplete blocks
developed from initial blocks chosen for the highest efficiency; r a
multiple of k), "alpha" (alpha design: resolvable, t / k blocks of
size k per replicate, k <= t / k, with the alpha array of highest
efficiency found)
and "lattice" (square lattice: k^2 treatments in blocks of k).
design_efficiency() reports the efficiency factor of the layout.
An object of class "ad_layout" with the field book (book),
the outlines of blocks and main plots (boxes), the skeleton ANOVA
(skeleton) and the seed used.
designs() for the table of designs, field_book(),
design_efficiency(), power_design().
designs("layout") # the designs that can be randomised lay <- make_design("rcbd", trt = c("N0", "N60", "N120", "N180"), r = 4, seed = 2026) lay head(lay$book) plot(lay) make_design("split_rcbd", A = c("Drip", "Furrow"), B = paste0("V", 1:4), r = 3, seed = 1)designs("layout") # the designs that can be randomised lay <- make_design("rcbd", trt = c("N0", "N60", "N120", "N180"), r = 4, seed = 2026) lay head(lay$book) plot(lay) make_design("split_rcbd", A = c("Drip", "Furrow"), B = paste0("V", 1:4), r = 3, seed = 1)
Compares the treatments of a one-way layout by the number of observations
above the grand median: a chi-square test on the 2 x t table of counts
above and at-or-below the median (Mood 1950; Conover 1999). Pairs of
treatments are compared with the same test on their 2 x 2 table, either
around the median of the two treatments together (pair_median = "pair",
the default) or around the grand median ("grand"), or with Fisher's
exact test (exact = TRUE). It assumes little more than independence,
and resists outliers and unequal spreads, at the cost of power.
median_test( x, response = NULL, treatment = NULL, alpha = 0.05, p_adjust = "holm", correct = FALSE, pair_median = c("pair", "grand"), exact = FALSE )median_test( x, response = NULL, treatment = NULL, alpha = 0.05, p_adjust = "holm", correct = FALSE, pair_median = c("pair", "grand"), exact = FALSE )
x |
An |
response, treatment
|
Column names when |
alpha |
Significance level of the pairwise comparisons. |
p_adjust |
Adjustment of the pairwise p-values, as in
|
correct |
Yates' continuity correction in the 2 x 2 tables (the overall test is corrected only when there are two treatments). |
pair_median |
Median used for the pairwise tables. |
exact |
Use Fisher's exact test for the pairwise tables. |
An object of class c("ad_median_test", "ad_nonparametric");
table holds the counts above and at-or-below the grand median and
grand_median the median of all observations.
Mood, A. M. (1950). Introduction to the Theory of Statistics. McGraw-Hill, New York, 394-399.
Conover, W. J. (1999). Practical Nonparametric Statistics, 3rd ed. Wiley, New York, section 4.3.
median_test(bean_varieties, "Yield_kg_plot", "Variety")median_test(bean_varieties, "Yield_kg_plot", "Variety")
Analysis of the mating designs of Comstock and Robinson (1948, 1952):
each male crossed with its own group of females (females nested within males).
every male crossed with every female of its set.
F2 (or other) plants used as males, each crossed with
the two inbred parents of the population (the testers, given in the
female column).
Males (and females) are nested within sets, and blocks within sets. When a plot holds several plants, the plot error (blocks x crosses within sets) is separated from the variation within plots. The table gives the expected mean squares; every term is tested against the mean square that differs from it only by its own component, and the components are their moment estimators with standard errors from Var(MS) = 2 MS^2 / df.
nc_design( data, response, male, female, block, set = NULL, design = 1, inbreeding = 0 )nc_design( data, response, male, female, block, set = NULL, design = 1, inbreeding = 0 )
data |
A data frame in long format. |
response |
Name of the numeric response column. |
male, female
|
Names of the male and female columns (design III: the female column holds the two testers). |
block |
Name of the block (replicate) column, nested within sets. |
set |
Optional name of the set column. |
design |
1, 2 or 3. |
inbreeding |
Inbreeding coefficient of the parents (designs I and II). |
Genetic interpretation without epistasis: design I,
sigma2_A = 4 Vm / (1 + F) and sigma2_D = 4 (Vf - Vm) / (1 + F)^2;
design II, sigma2_A = 2 (Vm + Vf) / (1 + F) and
sigma2_D = 4 Vmf / (1 + F)^2; design III (F2 reference population,
gene frequency 1/2), sigma2_A = 4 Vm = 2 (MSm - MSe) / r and
sigma2_D = Vmt = (MSmt - MSe) / r, because the sum and the difference
of the two backcross families of a plant have variances sigma2_A and
2 sigma2_D. The average degree of dominance is sqrt(2 sigma2_D / sigma2_A).
An object of class "ad_nc_design": the analysis of variance with
expected mean squares, the variance components and the genetic
parameters.
Comstock, R. E. and Robinson, H. F. (1948) Biometrics 4, 254-266. Comstock, R. E. and Robinson, H. F. (1952) In Heterosis, Iowa State College Press, 494-516.
nc_design(nc_designs$nc2, "Yield_t_ha", "Male", "Female", block = "Rep", set = "Set", design = 2) nc_design(nc_designs$nc3, "Yield_t_ha", "Male", "Tester", block = "Rep", set = "Set", design = 3)nc_design(nc_designs$nc2, "Yield_t_ha", "Male", "Female", block = "Rep", set = "Set", design = 2) nc_design(nc_designs$nc3, "Yield_t_ha", "Male", "Tester", block = "Rep", set = "Set", design = 3)
Simulated data of the three North Carolina designs, each in two sets with two replicates per set.
nc_designsnc_designs
A list of three data frames:
Design I: Set, Rep, Male (three per set), Female
(four per male, labelled within the male) and Yield_t_ha; 48 rows.
Design II: Set, Rep, Male and Female (four of each
per set) and Yield_t_ha; 64 rows.
Design III: Set, Rep, Male (six F2 plants per set),
Tester (P1, P2) and Yield_t_ha; 48 rows.
nc_design(nc_designs$nc1, "Yield_t_ha", "Male", "Female", block = "Rep", set = "Set", design = 1)nc_design(nc_designs$nc1, "Yield_t_ha", "Male", "Female", block = "Rep", set = "Set", design = 1)
When the assumptions fail, compares the treatments without assuming
normality (rank-based tests) or without assuming equal variances
(Welch). The method follows the design of fit:
nonparametric( fit, method = NULL, posthoc = c("conover", "nemenyi"), p_adjust = "holm", alpha = 0.05 )nonparametric( fit, method = NULL, posthoc = c("conover", "nemenyi"), p_adjust = "holm", alpha = 0.05 )
fit |
An |
method |
One of the methods above; |
posthoc |
For Friedman, |
p_adjust |
Adjustment of the pairwise p-values, as in
|
alpha |
Significance level of the checks. |
"kruskal": Kruskal-Wallis with Dunn's pairwise tests (one factor,
no blocks); "kruskal_mw" uses pairwise Mann-Whitney tests instead.
"welch": Welch's one-way ANOVA with Games-Howell pairwise tests (one
factor, no blocks; normal data with unequal variances).
"friedman": Friedman's test with Conover's or Nemenyi's pairwise
tests (one factor in complete blocks, one plot per block and treatment).
"srh": Scheirer-Ray-Hare extension of Kruskal-Wallis (two factors,
no blocks).
"art": aligned rank transform ANOVA (any factorial or blocked design
tested against the residual error), with Tukey comparisons on the
aligned ranks of the first treatment factor.
Pairwise p-values of Dunn, Mann-Whitney and Conover are adjusted with
p_adjust; Games-Howell, Nemenyi and Tukey already control the
family-wise error. Levels that share a letter do not differ.
An object of class "ad_nonparametric" with the test (test),
the table of terms for SRH and ART (table), the pairwise comparisons
(pairs) and the groups with their letters (groups).
fit <- design_anova(bean_varieties, "Yield_kg_plot", "Variety") nonparametric(fit) fit <- design_anova(disease_scores, "Severity_score", "Fungicide", block = "Block") nonparametric(fit, posthoc = "nemenyi")fit <- design_anova(bean_varieties, "Yield_kg_plot", "Variety") nonparametric(fit) fit <- design_anova(disease_scores, "Severity_score", "Fungicide", block = "Block") nonparametric(fit, posthoc = "nemenyi")
Least-squares means of every combination of two treatment factors as a coloured table with the values written in the cells.
plot_cell_means(fit, rows, cols, digits = 2, main = NULL)plot_cell_means(fit, rows, cols, digits = 2, main = NULL)
fit |
An |
rows, cols
|
Factors in the rows and columns of the map. |
digits |
Decimals of the values. |
main |
Title; |
Invisibly, the cell means plotted.
fit <- design_anova(tomato_factorial, "Yield_kg_plant", c("Variety", "Fertilizer"), block = "Block") plot_cell_means(fit, "Variety", "Fertilizer")fit <- design_anova(tomato_factorial, "Yield_kg_plant", c("Variety", "Fertilizer"), block = "Block") plot_cell_means(fit, "Variety", "Fertilizer")
Every pairwise difference of a comparison with its interval: the critical difference of the procedure (simultaneous for Tukey, Scheffe, Dunnett...) or, for Holm and Games-Howell, the 95 % t interval. Differences declared significant are drawn in red.
plot_differences( x, sort = TRUE, main = NULL, xlab = "Difference between means", col = c("#2f7d4f", "#b5432f") )plot_differences( x, sort = TRUE, main = NULL, xlab = "Difference between means", col = c("#2f7d4f", "#b5432f") )
x |
An |
sort |
Sort by the size of the difference. |
main, xlab
|
Titles. |
col |
Colours of non-significant and significant differences. |
Invisibly, the differences and interval limits plotted.
fit <- design_anova(bean_varieties, "Yield_kg_plot", "Variety") plot_differences(compare_means(fit, "Variety"))fit <- design_anova(bean_varieties, "Yield_kg_plot", "Variety") plot_differences(compare_means(fit, "Variety"))
Draws the plots of the trial on their field rows and columns, coloured by the response or by the residuals of the model (a diverging scale centred at zero), and labelled with the treatment. Spatial patterns of the residuals point to fertility gradients that blocking did not remove.
plot_field( fit, row = NULL, col = NULL, data = NULL, value = c("response", "residuals"), labels = TRUE, values = TRUE, digits = 2, main = NULL )plot_field( fit, row = NULL, col = NULL, data = NULL, value = c("response", "residuals"), labels = TRUE, values = TRUE, digits = 2, main = NULL )
fit |
An |
row, col
|
Names of the field row and column columns. By default the row and column of a Latin square. |
data |
The data frame given to |
value |
|
labels |
Write the treatment of each plot. |
values |
Write the value of each plot. |
digits |
Decimals of the values. |
main |
Title. |
Invisibly, a data frame with the row, column, treatment and value of every plot.
fit <- design_anova(wheat_latin, "Yield_t_ha", "Treatment", row = "Row", col = "Column") plot_field(fit, value = "residuals")fit <- design_anova(wheat_latin, "Yield_t_ha", "Treatment", row = "Row", col = "Column") plot_field(fit, value = "residuals")
Least-squares means of every combination of x (horizontal axis) and
trace (one line per level), with error bars.
plot_interaction( fit, x, trace, error = c("se", "ci", "none"), col = NULL, main = NULL, xlab = NULL, ylab = NULL, ylim = NULL )plot_interaction( fit, x, trace, error = c("se", "ci", "none"), col = NULL, main = NULL, xlab = NULL, ylab = NULL, ylim = NULL )
fit |
An |
x, trace
|
Treatment factors on the horizontal axis and as lines. |
error |
Error bars: |
col |
Fill colours, one per level (default: |
main, xlab, ylab
|
Titles; |
ylim |
Range of the vertical axis. |
Invisibly, the cell means plotted.
fit <- design_anova(tomato_factorial, "Yield_kg_plant", c("Variety", "Fertilizer"), block = "Block") plot_interaction(fit, "Fertilizer", "Variety")fit <- design_anova(tomato_factorial, "Yield_kg_plant", c("Variety", "Fertilizer"), block = "Block") plot_interaction(fit, "Fertilizer", "Variety")
A bar split into the share of the total sum of squares taken by every source of the analysis of variance, including the error strata and the residual.
plot_ss_partition(fit, col = NULL, main = NULL)plot_ss_partition(fit, col = NULL, main = NULL)
fit |
An |
col |
Colours of the sources. |
main |
Title. |
Invisibly, a data frame with the sum of squares and percentage of every source.
fit <- design_anova(split_irrigation, "Yield_t_ha", c("Irrigation", "Variety"), block = "Block", design = "split_rcbd") plot_ss_partition(fit)fit <- design_anova(split_irrigation, "Yield_t_ha", c("Irrigation", "Variety"), block = "Block", design = "split_rcbd") plot_ss_partition(fit)
The AMMI1 biplot puts the means of genotypes and environments on the horizontal axis and their first interaction score on the vertical axis; the AMMI2 biplot shows the first two interaction axes, with the environments as vectors from the origin.
## S3 method for class 'ad_ammi' plot( x, type = c("ammi1", "ammi2"), col = NULL, labels = TRUE, main = NULL, xlab = NULL, ylab = NULL, cex = 0.8, ... )## S3 method for class 'ad_ammi' plot( x, type = c("ammi1", "ammi2"), col = NULL, labels = TRUE, main = NULL, xlab = NULL, ylab = NULL, cex = 0.8, ... )
x |
An |
type |
|
col |
Two colours: genotypes and environments. |
labels |
Write the names of genotypes and environments. |
main, xlab, ylab
|
Titles; |
cex |
Size of the labels. |
... |
Further graphical parameters passed to |
Invisibly, a data frame with the coordinates of every point.
fit <- ammi(maize_met, "Yield_t_ha", "Hybrid", "Environment", block = "Block") plot(fit, type = "ammi2")fit <- ammi(maize_met, "Yield_t_ha", "Hybrid", "Environment", block = "Block") plot(fit, type = "ammi2")
Six diagnostic plots of the residuals: residuals against fitted values, normal Q-Q plot of the studentized residuals with a 95 % pointwise band, scale-location, residuals by treatment, residuals in data order and a histogram with the normal curve. Observations with |studentized residual| above 2.5 are labelled with their row number.
## S3 method for class 'ad_anova' plot(x, which = 1:6, ...)## S3 method for class 'ad_anova' plot(x, which = 1:6, ...)
x |
An |
which |
Plots to draw (1 to 6). Several plots share one page. |
... |
Not used. |
Invisibly, a data frame with the fitted values, residuals and studentized residuals.
fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") plot(fit) plot(fit, which = 2)fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") plot(fit) plot(fit, which = 2)
Draws the means of a comparison from compare_means() as bars or points
with error bars, or the observations as box plots or points, and writes
the letters of the groups above them. With simple effects (by), the
means are grouped by the levels of the other factor and the letters are
valid within each group.
## S3 method for class 'ad_comparison' plot( x, style = c("bars", "points", "box", "strip"), error = c("se", "ci", "none"), letters = TRUE, values = FALSE, sort = FALSE, col = NULL, main = NULL, xlab = NULL, ylab = NULL, ylim = NULL, letter_cex = 1.1, digits = 2, ... )## S3 method for class 'ad_comparison' plot( x, style = c("bars", "points", "box", "strip"), error = c("se", "ci", "none"), letters = TRUE, values = FALSE, sort = FALSE, col = NULL, main = NULL, xlab = NULL, ylab = NULL, ylim = NULL, letter_cex = 1.1, digits = 2, ... )
x |
An |
style |
|
error |
Error bars: |
letters |
Write the letters of the groups. |
values |
Write the value of each mean. |
sort |
Sort the levels by their mean, highest first. |
col |
Fill colours, one per level (default: |
main, xlab, ylab
|
Titles; |
ylim |
Range of the vertical axis. |
letter_cex |
Size of the letters. |
digits |
Decimals of the values written with |
... |
Further graphical parameters passed to |
Invisibly, a data frame with the position, mean, error-bar limits and letters of every level.
fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") cmp <- compare_means(fit, "Nitrogen_kg_ha") plot(cmp) plot(cmp, style = "box") fit <- design_anova(split_irrigation, "Yield_t_ha", c("Irrigation", "Variety"), block = "Block", design = "split_rcbd") plot(compare_means(fit, "Variety", by = "Irrigation"))fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") cmp <- compare_means(fit, "Nitrogen_kg_ha") plot(cmp) plot(cmp, style = "box") fit <- design_anova(split_irrigation, "Yield_t_ha", c("Irrigation", "Variety"), block = "Block", design = "split_rcbd") plot(compare_means(fit, "Variety", by = "Irrigation"))
Draws the plots on their field rows and columns coloured by treatment (or by main-plot factor), with the plot numbers and the outlines of blocks and main plots.
## S3 method for class 'ad_layout' plot(x, color_by = NULL, labels = TRUE, numbers = TRUE, main = NULL, ...)## S3 method for class 'ad_layout' plot(x, color_by = NULL, labels = TRUE, numbers = TRUE, main = NULL, ...)
x |
An |
color_by |
Column of the field book that colours the plots
(default: |
labels |
Write the treatment in each plot. |
numbers |
Write the plot number in each plot. |
main |
Title. |
... |
Not used. |
Invisibly, the field book.
plot(make_design("strip", A = c("Drip", "Furrow", "Sprinkler"), B = c("V1", "V2"), r = 2, seed = 3))plot(make_design("strip", A = c("Drip", "Furrow", "Sprinkler"), B = c("V1", "V2"), r = 2, seed = 3))
Power of the two-sided t-test to detect a difference of diff per cent
of the mean between two treatment means, when the coefficient of
variation of the trial is cv per cent, as a function of the number of
replicates. The error degrees of freedom are those of a CRD or an RCBD
with t treatments, and the power uses the noncentral t distribution.
power_design( cv, diff, t, design = c("rcbd", "crd"), alpha = 0.05, power = 0.8, r = 2:30 )power_design( cv, diff, t, design = c("rcbd", "crd"), alpha = 0.05, power = 0.8, r = 2:30 )
cv |
Coefficient of variation expected (per cent), from earlier trials on the same site and crop. |
diff |
Difference to detect, per cent of the mean. |
t |
Number of treatments. |
design |
|
alpha |
Significance level. |
power |
Power wanted. |
r |
Replicates for which the table is computed. |
An object of class "ad_power" with the replicates needed
(replicates, NA above 200) and a table with the error df, the power
and the detectable difference for each number of replicates.
power_design(cv = 15, diff = 15, t = 4) plot(power_design(cv = 10, diff = 15, t = 4))power_design(cv = 15, diff = 15, t = 4) plot(power_design(cv = 10, diff = 15, t = 4))
In incomplete block designs (alpha, lattice, BIBD, cyclic, augmented),
the intra-block analysis of design_anova() treats blocks as fixed and
uses only comparisons within blocks. When blocks are random, block totals
also carry information on the treatments. This function fits blocks as a
random effect, estimates the block and error variances by restricted
maximum likelihood (REML) and returns the treatment means as generalised
least-squares estimates (BLUEs), with their standard errors and the
efficiency gained over the intra-block analysis and over a complete block
design.
recover_interblock(fit)recover_interblock(fit)
fit |
An |
An object of class "ad_recovery" with the variance components
(sigma2_block, sigma2), the adjusted treatment means and SEs
(means), the average standard error of a difference for the combined,
intra-block and complete-block analyses, and the REML log-likelihood.
lay <- make_design("alpha", trt = 12, r = 3, k = 3, seed = 4) b <- field_book(lay, "Yield") b$Yield <- 10 + as.integer(factor(b$Treatment)) / 5 + rep(c(-1, 0, 1), length.out = nrow(b)) fit <- design_anova(b, "Yield", "Treatment", block = c("Block", "IncBlock")) recover_interblock(fit)lay <- make_design("alpha", trt = 12, r = 3, k = 3, seed = 4) b <- field_book(lay, "Yield") b$Yield <- 10 + as.integer(factor(b$Treatment)) / 5 + rep(c(-1, 0, 1), length.out = nrow(b)) fit <- design_anova(b, "Yield", "Treatment", block = c("Block", "IncBlock")) recover_interblock(fit)
Opens the graphics device that matches the extension of file (.png,
.tiff, .jpg, .pdf, .svg or .eps), evaluates the plotting code
and closes the device. Raster formats carry the resolution in their
header, as journals ask.
save_figure( file, expr, width = 16, height = 11, units = c("cm", "mm", "in"), res = 600, pointsize = 10 )save_figure( file, expr, width = 16, height = 11, units = c("cm", "mm", "in"), res = 600, pointsize = 10 )
file |
Output file; its extension chooses the format. |
expr |
Plotting code, for instance |
width, height
|
Size of the figure. |
units |
|
res |
Resolution in dots per inch of raster formats. |
pointsize |
Base size of the text, in points. |
The path of the file, invisibly.
fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") f <- tempfile(fileext = ".png") save_figure(f, plot(compare_means(fit, "Nitrogen_kg_ha")), width = 12, height = 9) file.exists(f)fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") f <- tempfile(fileext = ".png") save_figure(f, plot(compare_means(fit, "Nitrogen_kg_ha")), width = 12, height = 9) file.exists(f)
From a uniformity trial (one crop, uniformly managed, harvested in small
basic units) builds every plot shape that tiles the field exactly
(length units along the rows times width units along the columns),
computes for each the variance per unit area among plots,
V_x = var(T / x) with T the plot totals and x the plot size in basic
units, and fits Smith's empirical law V_x = V_1 / x^b by least squares
on the log scale (weighted by the degrees of freedom of each variance,
plots - 1, unless weights = "none").
smith_index( data, cost_ratio = NULL, weights = c("df", "none"), min_plots = 2, strips = FALSE )smith_index( data, cost_ratio = NULL, weights = c("df", "none"), min_plots = 2, strips = FALSE )
data |
A numeric matrix (or data frame) of yields of the basic units, with the rows and columns of the field. |
cost_ratio |
Optional ratio of the cost per plot to the cost per unit area of experimental land (both per basic unit). |
weights |
|
min_plots |
Smallest number of plots a shape must give to enter the fit (at least 2). |
strips |
Use in the fit the shapes that span the whole length or width of the field. They are left out by default (as in agricolae): one strip per row or column averages out any gradient along it, so a few such shapes can dominate the fit, and they cannot be blocked. |
The index b lies usually between 0 and 1. Near 1, adjacent units are
nearly uncorrelated and larger plots reduce the variance per unit area
efficiently; near 0, adjacent units are much alike and enlarging plots
gains little, so more replicates pay off better. Given the ratio of the
cost per plot to the cost per unit area (cost_ratio = K1 / K2), Smith's
optimum plot size is b K1 / ((1 - b) K2) basic units; see
hatheway_size() for the size needed to detect a given difference.
An object of class "ad_smith" with the table of shapes
(table: size, width, length, plots, df, variance, cv, used), the index
b, the fitted V1, the R squared of the log-log fit, the mean yield,
the coefficient of variation of the basic units (cv1) and Smith's
optimum plot size (optimum).
Smith, H. F. (1938). An empirical law describing heterogeneity in the yields of agricultural crops. Journal of Agricultural Science 28, 1-23.
Gomez, K. A. and Gomez, A. A. (1984). Statistical Procedures for Agricultural Research, 2nd ed. Wiley, New York, chapter 12.
sm <- smith_index(uniformity_trial, cost_ratio = 2) sm plot(sm)sm <- smith_index(uniformity_trial, cost_ratio = 2) sm plot(sm)
Two irrigation systems on main plots and four varieties on sub-plots, in three blocks.
split_irrigationsplit_irrigation
A data frame with 24 rows and 4 columns:
Block (1-3).
Irrigation system (main-plot factor).
Variety (sub-plot factor).
Yield, t/ha.
design_anova(split_irrigation, "Yield_t_ha", c("Irrigation", "Variety"), block = "Block", design = "split_rcbd")design_anova(split_irrigation, "Yield_t_ha", c("Irrigation", "Variety"), block = "Block", design = "split_rcbd")
Parametric and rank-based stability statistics computed from the table of genotype means in every environment and the pooled error of the trial:
"eberhart"Eberhart and Russell (1966): regression coefficient
b on the environmental index (with its standard error from the
genotype's own deviations, and a t test of b = 1), deviation mean
square s2d (mean scale, minus the error of a mean) with its F test
against the pooled error, and their analysis of variance.
"finlay"Finlay and Wilkinson (1963): regression on the environment mean, optionally on the log scale.
"shukla"Shukla's (1972) stability variance sigma2 and the
same after removing the linear regression on the environmental index
(s2), with F tests against the pooled error (plot scale).
"wricke"Wricke's (1962) ecovalence (plot scale) and its share of the interaction.
"kang"Kang's (1993) yield-stability statistic YS: the rank of the mean (highest = g), adjusted by the LSD, plus the stability rating from Shukla's test (-8, -4, -2 at 0.01, 0.05, 0.10).
"huehn"Huehn's (1979) rank statistics S1 and S2 on the ranks corrected for the genotype effects, with the Z tests of Nassar and Huehn (1987).
The common analysis of variance follows Shukla (1972): the interaction is split into the heterogeneity of the regressions and the residual, with (g - 1)(e - 2) degrees of freedom (Eberhart and Russell printed g(e - 2), but e - 2 of them belong to environments and are identically zero).
stability( data, response, genotype, environment, block = NULL, mse = NULL, df_error = NULL, reps = 1, method = c("eberhart", "finlay", "shukla", "wricke", "kang", "huehn"), alpha = 0.05, log_finlay = FALSE )stability( data, response, genotype, environment, block = NULL, mse = NULL, df_error = NULL, reps = 1, method = c("eberhart", "finlay", "shukla", "wricke", "kang", "huehn"), alpha = 0.05, log_finlay = FALSE )
data |
A data frame in long format. |
response |
Name of the numeric response column. |
genotype, environment
|
Names of the genotype and environment columns. |
block |
Optional name of the block (replicate) column; blocks are taken as nested within environments. |
mse, df_error
|
Error mean square (plot scale) and its degrees of freedom, only when the data hold one mean per cell. |
reps |
Number of replicates behind each mean, when the data hold one mean per cell. |
method |
One or more of |
alpha |
Significance level of the LSD in Kang's statistic and of the critical values of Huehn's tests. |
log_finlay |
Fit the regression of Finlay and Wilkinson on the natural logarithm of the means, as in their paper. |
An object of class "ad_stability": the analysis of variance
(anova) and one element per method.
Eberhart, S. A. and Russell, W. A. (1966) Crop Science 6, 36-40. Finlay, K. W. and Wilkinson, G. N. (1963) Australian Journal of Agricultural Research 14, 742-754. Shukla, G. K. (1972) Heredity 29, 237-245. Wricke, G. (1962) Zeitschrift fur Pflanzenzuchtung 47, 92-96. Kang, M. S. (1993) Agronomy Journal 85, 754-757. Huehn, M. (1979) EDV in Medizin und Biologie 10, 112-117. Nassar, R. and Huehn, M. (1987) Biometrics 43, 45-53.
st <- stability(maize_met, "Yield_t_ha", "Hybrid", "Environment", block = "Block") st st$kangst <- stability(maize_met, "Yield_t_ha", "Hybrid", "Environment", block = "Block") st st$kang
A contrast compares groups of treatments with coefficients that sum to
zero, one per level in the order of levels(fit$data[[factor]]); for
instance a control against the other three treatments is c(3, -1, -1, -1).
test_contrasts(fit, factor, coef)test_contrasts(fit, factor, coef)
fit |
An |
factor |
Treatment factor whose means are compared; two names compare
all their combinations together (not available for split- or
strip-plots, where |
coef |
A vector of coefficients, or a matrix with one contrast per row (row names are used as labels). |
A data frame with the estimate, its SE, t, p, the sum of squares
of the contrast and F (1 and df_error degrees of freedom).
fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") test_contrasts(fit, "Nitrogen_kg_ha", rbind("0 vs fertilised" = c(3, -1, -1, -1), "120 vs 180" = c(0, 0, 1, -1)))fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") test_contrasts(fit, "Nitrogen_kg_ha", rbind("0 vs fertilised" = c(3, -1, -1, -1), "120 vs 180" = c(0, 0, 1, -1)))
Three tomato varieties by three fertiliser levels in three blocks.
tomato_factorialtomato_factorial
A data frame with 27 rows and 5 columns:
Block (1-3).
Tomato variety.
Fertiliser level (F0, F1, F2).
Fruit yield, kg per plant.
Plant height, cm.
design_anova(tomato_factorial, "Yield_kg_plant", c("Variety", "Fertilizer"), block = "Block")design_anova(tomato_factorial, "Yield_kg_plant", c("Variety", "Fertilizer"), block = "Block")
Refits the design after each transformation that suits the range of the response and repeats the assumption checks. A transformation is suggested only when the original scale fails some check and the transformed scale passes all of them: the conventional power nearest to the Box-Cox estimate when it passes, otherwise the candidate with the least evidence against the assumptions.
transformations(fit, alpha = 0.05)transformations(fit, alpha = 0.05)
fit |
An |
alpha |
Significance level of the checks. |
An object of class "ad_transformations": the table of candidates
(table), the identifier of the suggested transformation (suggested,
NULL when none is needed or none works), a short verdict and the
Box-Cox profile (box_cox).
fit <- design_anova(tomato_factorial, "Yield_kg_plant", c("Variety", "Fertilizer"), block = "Block") transformations(fit)fit <- design_anova(tomato_factorial, "Yield_kg_plant", c("Variety", "Fertilizer"), block = "Block") transformations(fit)
Splits the sum of squares of a factor with numeric levels (doses, rates, dates) into linear, quadratic, cubic... components with orthogonal polynomial contrasts (also with unequal spacing) and fits the polynomial of the highest significant degree to the observations. A fitted quadratic reports where the maximum (or minimum) response lies.
trend(fit, factor, degree = NULL, alpha = 0.05)trend(fit, factor, degree = NULL, alpha = 0.05)
fit |
An |
factor |
Treatment factor whose means are compared; two names compare
all their combinations together (not available for split- or
strip-plots, where |
degree |
Highest degree to test (default: up to 4, at most the number of levels minus one). |
alpha |
Significance level. |
An object of class "ad_trend" with the table of components
(components), the fitted coefficients (coef, intercept first), its
R squared and the optimum of a quadratic (optimum).
fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") trend(fit, "Nitrogen_kg_ha")fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") trend(fit, "Nitrogen_kg_ha")
Simulated yields (kg) of a uniformity trial harvested in 384 basic units (24 rows by 16 columns), with a fertility gradient along the rows and patchy variation; suited to Smith's index of soil heterogeneity.
uniformity_trialuniformity_trial
A numeric matrix with 24 rows (R1...R24) and 16 columns
(C1...C16).
smith_index(uniformity_trial)smith_index(uniformity_trial)
Compares the treatments of a one-way layout (no blocks) after replacing
every observation by its normal score qnorm(R / (N + 1)), where R is
its rank among all N observations (average ranks for ties). The
statistic is chi-square with t - 1 degrees of freedom; the pairwise
comparisons are Conover's t tests on the mean scores with N - t
degrees of freedom. It is as powerful as the F test under normality and
more robust than it.
waerden_test( x, response = NULL, treatment = NULL, alpha = 0.05, p_adjust = "holm" )waerden_test( x, response = NULL, treatment = NULL, alpha = 0.05, p_adjust = "holm" )
x |
An |
response, treatment
|
Column names when |
alpha |
Significance level of the pairwise comparisons. |
p_adjust |
Adjustment of the pairwise p-values, as in
|
An object of class c("ad_waerden", "ad_nonparametric"); the
groups carry the mean normal score of every level (mean_score).
van der Waerden, B. L. (1952). Order tests for the two-sample problem and their power. Indagationes Mathematicae 14, 453-458.
Conover, W. J. (1999). Practical Nonparametric Statistics, 3rd ed. Wiley, New York, section 5.10.
waerden_test(bean_varieties, "Yield_kg_plot", "Variety")waerden_test(bean_varieties, "Yield_kg_plot", "Variety")
The Bayesian critical value t_B(K, F, q, f) of Waller and Duncan (1969),
computed by numerical integration of the posterior expected losses (see
waller_duncan()). Two means differ when their difference exceeds
t_B * SE, the Bayes least significant difference. The value decreases
as the observed F grows: with a small F the means are shrunk towards
each other and few differences are declared.
waller_critical(K = 100, q, f, F_ratio)waller_critical(K = 100, q, f, F_ratio)
K |
Ratio of the seriousness of a type I error to that of a type II error (50, 100 and 500 roughly match alpha = 0.10, 0.05 and 0.01). |
q, f
|
Degrees of freedom of the treatments and of the error. |
F_ratio |
Observed F ratio of the treatments. |
A numeric vector of critical values (arguments are recycled).
Waller, R. A. and Duncan, D. B. (1969). A Bayes rule for the symmetric multiple comparisons problem. Journal of the American Statistical Association 64, 1484-1503.
Waller, R. A. and Kemp, K. E. (1975). Computations of Bayesian t-values for multiple comparisons. Journal of Statistical Computation and Simulation 4, 169-171.
waller_critical(100, q = 5, f = 24, F_ratio = 14.37) waller_critical(100, q = 4, f = 20, F_ratio = c(2, 5, 10, 100))waller_critical(100, q = 5, f = 24, F_ratio = 14.37) waller_critical(100, q = 4, f = 20, F_ratio = c(2, 5, 10, 100))
Bayesian separation of the means of a treatment factor (Waller and Duncan
1969). Instead of a fixed significance level, the user gives the ratio
K of the seriousness of a type I to a type II error; the critical t
then adapts to the evidence of the analysis of variance: with a large F
it approaches an unprotected LSD, with an F near 1 almost no difference is
declared. The result is an "ad_comparison" object, so print(),
plot() and plot_differences() work as with compare_means().
waller_duncan(fit, factor, K = 100, alpha = NULL)waller_duncan(fit, factor, K = 100, alpha = NULL)
fit |
An |
factor |
One treatment factor of |
K |
Seriousness ratio of type I to type II errors (default 100). |
alpha |
Optional nominal level that sets |
The F, its degrees of freedom and the error come from the stratum that
tests the factor in fit (for instance Error a for the main plots of a
split-plot). With unequal replication every pair uses its own standard
error, as in the Tukey-Kramer form.
An object of class "ad_comparison" (see compare_means()),
with the extra elements K, t_critical and F.
Waller, R. A. and Duncan, D. B. (1969). A Bayes rule for the symmetric multiple comparisons problem. Journal of the American Statistical Association 64, 1484-1503.
waller_critical(), compare_means()
fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") wd <- waller_duncan(fit, "Nitrogen_kg_ha") wd plot(wd)fit <- design_anova(maize_nitrogen, "Yield_t_ha", "Nitrogen_kg_ha", block = "Block") wd <- waller_duncan(fit, "Nitrogen_kg_ha") wd plot(wd)
Wheat yield in a 4 x 4 Latin square
wheat_latinwheat_latin
A data frame with 16 rows and 4 columns:
Row of the field (1-4).
Column of the field (1-4).
Treatment (A-D).
Grain yield, t/ha.
design_anova(wheat_latin, "Yield_t_ha", "Treatment", row = "Row", col = "Column")design_anova(wheat_latin, "Yield_t_ha", "Treatment", row = "Row", col = "Column")