Evaluates the structure of an agricultural or biological experimental dataset, auditing treatment balance, blocking completeness, hierarchical split-plot structures, repeated measures, missing experimental units, and response variable distribution.
Usage
check_design(
data,
response,
treatment = NULL,
block = NULL,
main_plot = NULL,
sub_plot = NULL,
sub_sub_plot = NULL,
time = NULL,
subject = NULL,
row = NULL,
col = NULL,
covariates = NULL
)Arguments
- data
A `data.frame` or `tibble` containing the experimental data.
- response
Character string with the column name of the response variable.
- treatment
Character vector specifying one or more treatment factor column names.
- block
Optional character string specifying the blocking factor column name (e.g., `"block"`, `"replicate"`).
- main_plot
Optional character string for split-plot designs specifying the whole-plot factor.
- sub_plot
Optional character string for split-plot designs specifying the sub-plot factor.
- sub_sub_plot
Optional character string for split-split-plot designs.
- time
Optional character string specifying the time factor column for repeated measures.
- subject
Optional character string specifying the experimental unit or subject ID for longitudinal/repeated data.
- row
Optional character string for row-column or Latin square designs.
- col
Optional character string for row-column or Latin square designs.
- covariates
Optional character vector of continuous baseline covariates.
Value
An S3 object of class `"agri_design_check"` containing:
- design_type
Detected canonical experimental design (e.g. CRD, RCBD, Split-Plot, Repeated Measures).
- balance_status
Character indicating whether the design is `"balanced"`, `"unbalanced"` (unequal replication), or `"incomplete"` (missing cells).
- treatment_summary
Detailed replication table and summary statistics across treatment combinations.
- blocking_summary
Audit of block sizes and orthogonality with treatments (if blocking is specified).
- hierarchy_summary
Summary of whole-plot and sub-plot error levels (if split-plot is specified).
- repeated_summary
Summary of time-point intervals and subject completeness (if repeated measures is specified).
- response_audit
Audit of missingness, range, zeros, and suggested distributional family.
- covariates_summary
Summary and correlation of continuous covariates with response.
- warnings
List of potential statistical risks (e.g. low block degrees of freedom, empty cells, boundary singularity alerts).
Examples
data(wheat_splitplot, package = "agriDesignR")
diag <- check_design(
data = wheat_splitplot,
response = "grain_yield",
main_plot = "temperature",
sub_plot = "genotype",
block = "block"
)
print(diag)
#>
#> ======================================================================
#> agriDesignR: Experimental Design Diagnostic Audit
#> ======================================================================
#> Dataset : wheat_splitplot
#> Response (Y) : grain_yield (40 obs, 0 missing)
#> Detected Design: Split-Plot Design (Parcelas Divididas)
#> Balance Status : [OK] PERFECTLY BALANCED
#>
#> 1. Treatment Factor Architecture
#> ----------------------------------------------------------------------
#> Factors (2) : temperature, genotype
#> * temperature: 2 levels
#> * genotype: 5 levels
#> Combinations : 10 treatment cells
#> Replications : Min = 4, Median = 4, Max = 4
#>
#> 2. Blocking & Local Control
#> ----------------------------------------------------------------------
#> Block Factor : block (4 blocks)
#> Completeness : [OK] Complete (all trts in all blocks)
#>
#> 3. Hierarchical Split-Plot Error Units
#> ----------------------------------------------------------------------
#> Main-Plot (Whole) : temperature (2 levels, df Error A = 3)
#> Sub-Plot : genotype (5 levels, df Error B = 24)
#>
#> 6. Response Distribution & Family Suggestion
#> ----------------------------------------------------------------------
#> Data Nature : Continuous Numeric
#> Zero Values : 0% zeros
#> Skewness Est. : -0.58
#> Suggested Fam. : gaussian (standard normal linear model)
#>
#> [WARN] Experimental Diagnostics & Actionable Warnings
#> ----------------------------------------------------------------------
#> [!] Block factor has 4 levels. In lme4::lmer, random effect variance may collapse to 0. Consider REML with Kenward-Roger df or fixed blocks.
#> [!] Whole-plot error degrees of freedom is very low (df = 3). Statistical power for testing main-plot factor 'temperature' will be severely limited.
#>
#> ======================================================================
#> Tip: Run 'suggest_model(diag)' to generate recommended model syntax.
#>
