Comprehensive Analysis of Variance (ANOVA) Engine for Completely Randomized Design (CRD)
anova_crd.RdThe `anova_crd` function executes a complete, high-precision linear model analysis for agricultural, laboratory, or greenhouse trials laid out under a Completely Randomized Design (CRD). It computes partition sums of squares, hypothesis testing statistics, treatment variances, significance flags, and the Coefficient of Variation (CV
Arguments
- data
A verified
data.framecontaining the columnsGenotypeand the target phenotypic trait response.- trait
A single character string specifying the exact column name of the numeric trait to analyze.
- reporting_level
An integer flag defining console trace settings:
0for silent execution,1for printing basic ANOVA summary tables, and2for comprehensive diagnostic trace logs. Defaults to2.
Value
Invisibly returns a structured named list of class "list" containing 4 computational components:
- anova_table
A
data.frameacting as the standard ANOVA source matrix table for CRD, containing degrees of freedom, sums of squares, mean squares, F-statistics, and p-values.- cv_percentage
A numeric scalar representing the computed Coefficient of Variation percentage (CV%).
- mean_square_error
A numeric scalar representing the isolated Residual Error Mean Square (EMS), ready for downstream evaluation.
- grand_mean
A numeric scalar representing the overall arithmetic mean value of the evaluated phenotypic trait.
If reporting_level >= 1, the compiled ANOVA table along with the grand mean and CV% are printed directly to the console before returning the list.
Details
In laboratory experiments, growth chamber studies, or field trials with completely homogeneous environments, blocking is unnecessary. This function utilizes standard least-squares projection to build the classic orthogonal CRD ANOVA matrix, modeling the response vector as a function of treatment effects without blocking constraints: $$Y_{ij} = \mu + T_i + \varepsilon_{ij}$$ Where \(T_i\) represents the treatment/genotype effect, and \(\varepsilon_{ij}\) is the residual experimental error. The function handles both balanced and unbalanced data structures perfectly, ensuring proper adjustments to degrees of freedom if replication numbers vary across lines.
Examples
# Execute complete CRD partition on your actual target trait (GYPM)
crd_results <- anova_crd(data = gv_data, trait = "GYPM")
#> =====================================================================================
#> AGRIDATATOOLS PACKAGED ENGINE v0.1.0 - COMPLETELY RANDOMIZED DESIGN (CRD) ANOVA
#> Analysis Inception: 2026-08-17 12:02:15.203653
#> -------------------------------------------------------------------------------------
#> [DIAGNOSTIC - MODEL]: Fitting one-way orthogonal linear model matrix formulas...
#>
#> ---------------------------------------------------------------------------
#> ANALYSIS OF VARIANCE (ANOVA) FOR CRD - TRAIT: GYPM
#> ---------------------------------------------------------------------------
#> Source Df SS MS F_value p_value
#> Genotypes (Treatments) 39 73217.300 1877.3667 109.895 < 0.001
#> Error (Residual) 80 1366.667 17.0833 NA NA
#> Total 119 74583.967 NA NA NA
#> ---------------------------------------------------------------------------
#> Trial Grand Mean : 104.9833
#> Coefficient of Variation (CV%) : 3.94 %
#> =====================================================================================
#>
#> [LOG - FINALIZE]: CRD matrix compilation finished in 0.00539 seconds.