Intelligent recommendations for heteroscedasticity diagnostics
generateHeteroRecommendations.RdThese helpers assemble an end-to-end recommendation workflow that profiles the input dataset, selects appropriate heteroscedasticity diagnostics, interprets results with qualitative confidence labels, and suggests remediation strategies with decision-tree style guidance.
Usage
analyseDatasetCharacteristics(data, response = NULL)
suggestDiagnosticsForProfile(profile)
interpretHeteroTestResults(test_results, alpha = 0.05)
recommendRemediationStrategies(test_results, model, data, profile = NULL)
warnDiagnosticAssumptions(profile, interpretations, model, data, test_results)
buildDiagnosticDecisionTree(profile, recommendations)
composeDiagnosticNarrative(profile, interpretations, remediation,
assumption_warnings, decision_tree)
generateHeteroRecommendations(model, data = NULL, test_results = NULL,
alpha = 0.05, include_report = TRUE)Arguments
- data
A
data.framecontaining the modelling variables.- response
Optional response variable name used for labelling.
- profile
Dataset profile produced by
analyseDatasetCharacteristics().- test_results
Named list of
htestobjects, typically returned byrunHeteroTests().- alpha
Significance level applied when interpreting p-values.
- model
Fitted
lm/glmobject or model formula.- interpretations
Output from
interpretHeteroTestResults().- recommendations
Output from
suggestDiagnosticsForProfile(), used to build the decision tree.- remediation
Output from
recommendRemediationStrategies().- assumption_warnings
Character vector of generated warnings.
- decision_tree
Data frame returned by
buildDiagnosticDecisionTree().- include_report
Logical; include a plain-language narrative in the output.
Value
analyseDatasetCharacteristics() returns a list describing dataset size,
missingness, skewness, and risk factors. suggestDiagnosticsForProfile()
returns a data frame of recommended diagnostics with rationales.
interpretHeteroTestResults() yields a tidy data frame of interpretations
and an overall summary. recommendRemediationStrategies() produces a
structured remediation plan. warnDiagnosticAssumptions() returns
warnings about assumption violations. buildDiagnosticDecisionTree()
constructs a tidy decision tree. composeDiagnosticNarrative() outputs a
plain-language character vector, and generateHeteroRecommendations()
returns an object of class hetero_recommendation_report bundling all
components.
Details
The recommendation engine analyses dataset characteristics such as sample size, missingness, and predictor skewness to propose diagnostics tailored to the context. It automatically interprets test outcomes, attaches qualitative confidence labels, warns when assumptions are at risk, and suggests remediation strategies matched to detected variance patterns. The generated decision tree and narrative target non-specialist audiences who need actionable guidance.
Examples
model <- lm(mpg ~ wt + hp, data = mtcars)
recs <- generateHeteroRecommendations(model, mtcars)
print(recs)
#> Heteroscedasticity Recommendation Overview
#> --------------------------------------------------
#> Observations: 32 | Variables: 11
#> Sample size category: small
#> Missingness: none (0.0%)
#>
#> Key recommendations:
#> - breusch_pagan: Baseline regression-based heteroscedasticity check.
#> - quantile_regression: Variables carb show strong skewness; quantile slope comparisons provide a complementary distributional check.
#> - rank_permutation: Rank-based test is robust when asymptotics are unreliable.
#> - white: Detects general forms of non-constant variance.
#> - wild_bootstrap: Bootstrap inference performs well in small samples.
#>
#> Summary:
#> No strong evidence of heteroscedasticity across the evaluated diagnostics.
#> No remediation required.
#>
#> Narrative excerpt:
#> Heteroscedasticity Diagnostic Recommendation Report
#> Observations: 32; Variables: 11
#> Sample size category: small
#> Missingness level: none (0.0% overall)
#> Response variable: mpg
#>
#> ...