sqi_anova: One-Way ANOVA and Tukey HSD Post-Hoc Test for SQI

View source: R/statistics.R

sqi_anovaR Documentation

One-Way ANOVA and Tukey HSD Post-Hoc Test for SQI

Description

Performs a one-way ANOVA to test whether Soil Quality Index values differ significantly across land-use groups, followed by Tukey's Honest Significant Difference (HSD) test for pairwise comparisons.

Usage

sqi_anova(scored, sqi_col, group_col, alpha = 0.05)

Arguments

scored

A scored data frame from score_all.

sqi_col

Character. Name of the SQI column to test (e.g., "SQI_linear"). This must be a column in scored or returned by one of the indexing functions joined back to the data. Alternatively pass the output of sqi_compare with individual observations merged in.

group_col

Character. Grouping variable column name (e.g., "LandUse").

alpha

Numeric. Significance level for the ANOVA. Default 0.05.

Value

A list with:

anova_table

An anova object.

tukey

A TukeyHSD object.

significant

Logical. Whether the ANOVA is significant at alpha.

compact_letters

Data frame of compact letter display for plotting.

References

Tukey, J.W. (1949). Comparing individual means in the analysis of variance. Biometrics, 5(2), 99–114. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/3001913")}

Examples

data(soil_data)
cfg <- make_config(
  variable = c("pH","EC","BD","OC","MBC","Clay"),
  type     = c("opt","less","less","more","more","opt"),
  opt_low  = c(6.0, NA, NA, NA, NA, 20),
  opt_high = c(7.0, NA, NA, NA, NA, 35)
)
scored <- score_all(soil_data, cfg, group_cols = c("LandUse","Depth"))
# Compute per-observation linear SQI for ANOVA
scored$SQI_obs <- rowMeans(scored[, cfg$variable], na.rm = TRUE)
aov_result <- sqi_anova(scored, sqi_col = "SQI_obs",
                         group_col = "LandUse")
print(aov_result$tukey)


SQIpro documentation built on April 20, 2026, 5:06 p.m.