Skip to contents

Synthesizes experimental topology, statistical modeling decisions, assumption audits, ANOVA hypothesis tests, biological rankings with effect sizes, and design relative efficiency into a complete, publication-ready Markdown or text narrative.

Usage

experiment_report(fit, post = NULL, efficiency = NULL, output_file = NULL)

Arguments

fit

An object of class `"agri_fitted_model"` returned by fit_experiment.

post

Optional object of class `"agri_posthoc"`. If `NULL`, computed automatically.

efficiency

Optional object of class `"agri_design_efficiency"`. If `NULL`, computed automatically.

output_file

Optional character path to save the Markdown report (e.g., `"experiment_report.md"`).

Value

An S3 object of class `"agri_report"` containing the structured text report and data objects.

Examples

data(wheat_splitplot, package = "agriDesignR")
fit <- fit_experiment(
  data = wheat_splitplot,
  response = "grain_yield",
  main_plot = "temperature",
  sub_plot = "genotype",
  block = "block"
)
rep <- experiment_report(fit)
#> Note: adjust = "tukey" was changed to "sidak"
#> because "tukey" is only appropriate for one set of pairwise comparisons
print(rep)
#> # Scientific & Statistical Report: grain_yield
#> **Generated by**: `agriDesignR` | **Date**: 2026-08-26
#> 
#> ## 1. Experimental Topology & Modeling Strategy
#> The experiment was conducted under a **Split-Plot Design (Parcelas Divididas)** evaluating response variable `grain_yield` across treatment factor(s) `temperature, genotype`. A **LMM (Linear Mixed-Effects Model)** was fitted using the `lme4` computational engine (gaussian distribution family). Random effects were structured as `(1 | block) + (1 | block:temperature)`, properly partitioning variance components according to the physical field/greenhouse hierarchy.
#> 
#> ## 2. Model Diagnostics & Assumption Verification
#> Residual assumptions were systematically audited. Normality of residuals was evaluated via Shapiro-Wilk test (W = 0.98, p = 0.6964), indicating that the normality assumption was **PASSED**. Homogeneity of variance across treatment groups showed a maximum-to-minimum variance ratio of 21.36x (Status: **ACCEPTABLE**). Minor to moderate deviations were detected; if necessary, 'remedy(fit)' can be utilized to evaluate Box-Cox or variance weighting structures.
#> 
#> ## 3. Analysis of Variance & Significance
#> ```text
#> Type III Analysis of Variance Table with Kenward-Roger's method
#>                       Sum Sq Mean Sq NumDF DenDF F value    Pr(>F)    
#> temperature           359.95  359.95     1     3  75.346  0.003217 ** 
#> genotype             1584.58  396.15     4    24  82.923 1.086e-13 ***
#> temperature:genotype  238.75   59.69     4    24  12.494 1.238e-05 ***
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> ```
#> 
#> ## 4. Agronomic Performance Ranking & Effect Sizes
#> Comparison family: treatment = temperature x genotype, conditioned by none, adjustment = tukey, alpha = 0.05, estimand = estimated marginal means. Multiple pairwise comparisons with compact letter displays identified distinct statistical tiers. The top-performing treatment level was **`1 : 4`** with an estimated mean of 65.71 (+13.76% relative to the baseline `Control_22C : G1`, Cohen's d = 1.32).
#> 
#> ```text
#>  Rank temperature genotype Mean_Estimate    SE Delta_vs_Ctrl Percent_Gain
#>     1 Control_22C       G4        65.710 2.273         7.947        13.76
#>     2 Control_22C       G2        62.648 2.273         4.885         8.46
#>     3 Control_22C       G5        58.880 2.273         1.117         1.93
#>     4 Control_22C       G1        57.763 2.273         0.000         0.00
#>     5    Heat_36C       G4        56.985 2.273        -0.778        -1.35
#>     6 Control_22C       G3        53.998 2.273        -3.765        -6.52
#>     7    Heat_36C       G2        44.330 2.273       -13.433       -23.25
#>     8    Heat_36C       G5        42.733 2.273       -15.030       -26.02
#>     9    Heat_36C       G1        39.630 2.273       -18.133       -31.39
#>    10    Heat_36C       G3        30.130 2.273       -27.633       -47.84
#>  Cohen_d Group
#>     1.32     d
#>     0.81    ad
#>     0.19    ab
#>     0.00    ab
#>    -0.13   abd
#>    -0.63    be
#>    -2.23    ce
#>    -2.50     c
#>    -3.01     c
#>    -4.59     f
#> ```
#> 
#> ## 5. Experimental Design Relative Efficiency (RE)
#> Relative efficiency analysis demonstrated an RE of **208.23%** compared to a completely randomized design (CRD). [OK] Highly Effective Blocking: The blocking factor 'block' increased experimental precision by 108.23% compared to an unblocked DCA (CRD). A CRD would have required 2.08x more replications per treatment to detect the same effect size.
#>