Advanced statistical tests using functions from the DescTools package. Includes effect size calculations (Cohen's D), goodness-of-fit tests (Hosmer-Lemeshow, Anderson-Darling), agreement tests (Barnard, Breslow-Day), and trend tests (Cochran-Armitage). Essential for clinical research, epidemiological studies, and advanced statistical analysis.
Usage
desctools(
data,
effect_size_analysis = FALSE,
group_var = NULL,
continuous_var = NULL,
pooled_sd = TRUE,
hedges_correction = FALSE,
effect_ci_level = 0.95,
goodness_of_fit = FALSE,
fitted_probs = NULL,
observed_outcomes = NULL,
hl_groups = 10,
normality_var = NULL,
categorical_tests = FALSE,
cat_var1 = NULL,
cat_var2 = NULL,
stratum_var = NULL,
ordered_exposure = NULL,
binary_outcome = NULL,
multiple_testing = "none",
show_effect_sizes = TRUE,
show_goodness_tests = TRUE,
show_categorical_tests = TRUE,
show_interpretations = TRUE
)
Arguments
- data
The data as a data frame for statistical analysis.
- effect_size_analysis
Calculate effect sizes including Cohen's D for comparing group means. Essential for determining practical significance in clinical studies.
- group_var
Categorical variable defining groups for effect size comparison. Should have exactly 2 levels for Cohen's D calculation.
- continuous_var
Continuous variable for effect size calculation (outcome measure).
- pooled_sd
Use pooled standard deviation for Cohen's D calculation. Recommended when group variances are similar.
- hedges_correction
Apply Hedges correction for small sample bias in effect size calculation.
- effect_ci_level
Confidence level for effect size confidence intervals.
- goodness_of_fit
Perform goodness of fit tests including Hosmer-Lemeshow test for logistic regression models and normality tests.
- fitted_probs
Fitted probabilities from a logistic regression model for Hosmer-Lemeshow goodness of fit test.
- observed_outcomes
Observed binary outcomes (0/1) for Hosmer-Lemeshow test.
- hl_groups
Number of groups for Hosmer-Lemeshow test. Usually 10 groups provide good balance between power and stability.
- normality_var
Continuous variable for normality testing using Anderson-Darling and other goodness of fit tests.
- categorical_tests
Perform advanced tests for categorical data including Barnard's test, Breslow-Day test, and Cochran-Armitage trend test.
- cat_var1
First categorical variable for contingency table analysis.
- cat_var2
Second categorical variable for contingency table analysis.
- stratum_var
Stratification variable for Breslow-Day test of homogeneity of odds ratios across strata.
- ordered_exposure
Ordered exposure variable for Cochran-Armitage trend test. Should represent ordered dose or exposure levels.
- binary_outcome
Binary outcome variable for Cochran-Armitage trend test.
- multiple_testing
Method for correcting p-values when multiple tests are performed. FDR (Benjamini-Hochberg) is recommended for most clinical studies.
- show_effect_sizes
Display effect size calculations including Cohen's D with confidence intervals and interpretation.
- show_goodness_tests
Display goodness of fit test results including Hosmer-Lemeshow and normality tests.
- show_categorical_tests
Display results of advanced categorical data tests.
- show_interpretations
Provide clinical interpretations and guidelines for statistical results to aid in medical decision making.
Value
A results object containing:
results$instructions | a html | ||||
results$effect_size_results | a html | ||||
results$goodness_fit_results | a html | ||||
results$categorical_results | a html |
Examples
# Load example data
data("histopathology")
data("dca_test_data")
data("BreastCancer")
# Example 1: Effect Size Analysis - Compare age between treatment groups
desctools(
data = histopathology,
effect_size_analysis = TRUE,
group_var = "Group",
continuous_var = "Age",
pooled_sd = TRUE,
hedges_correction = FALSE,
effect_ci_level = 0.95
)
#>
#> ADVANCED STATISTICAL TESTS
#>
#> character(0)
#>
#> <div style='font-family: Arial, sans-serif;'>
#>
#> Effect Size Analysis
#>
#> Group Summary Statistics
#>
#> <table border='1' cellpadding='5' cellspacing='0'
#> style='border-collapse: collapse;'><tr style='background-color:
#> #f0f0f0; font-weight:
#> bold;'>GroupNMeanSDMinMaxControl12049.82514.4152673Treatment12848.96913.2562573
#>
#> Effect Size Results
#>
#> <table border='1' cellpadding='5' cellspacing='0'
#> style='border-collapse: collapse;'><tr style='background-color:
#> #f0f0f0; font-weight: bold;'>MeasureValueLower CIUpper
#> CIMagnitudeCohen's d0.062-0.1870.311Negligible
#>
#> Clinical Interpretation
#>
#> <div style='background-color: #f9f9f9; padding: 10px; border-left: 4px
#> solid #007acc;'>
#>
#> Effect Size Interpretation: The effect size is negligible, suggesting
#> minimal practical difference between groups.
#>
#> Cohen's Conventions:
#>
#> Small effect: d = 0.2Medium effect: d = 0.5Large effect: d = 0.8
# Example 2: Goodness of Fit - Hosmer-Lemeshow test for model validation
desctools(
data = dca_test_data,
goodness_of_fit = TRUE,
fitted_probs = "basic_model",
observed_outcomes = "cardiac_event_numeric",
hl_groups = 10
)
#>
#> ADVANCED STATISTICAL TESTS
#>
#> character(0)
#>
#> <div style='font-family: Arial, sans-serif;'>
#>
#> Goodness of Fit Tests
#>
#> Hosmer-Lemeshow Goodness of Fit Test
#>
#> <table border='1' cellpadding='5' cellspacing='0'
#> style='border-collapse: collapse;'><tr style='background-color:
#> #f0f0f0; font-weight: bold;'>StatisticValuedfp-valueC
#> Statistic25.582480.0012
#>
#> Interpretation: Poor model fit (p ≤ 0.05). Consider model revision or
#> additional predictors.
# Example 3: Categorical Analysis - Test for trend across tumor grades
desctools(
data = histopathology,
categorical_tests = TRUE,
ordered_exposure = "Grade",
binary_outcome = "Death"
)
#>
#> ADVANCED STATISTICAL TESTS
#>
#> <div style='color: red; font-weight: bold;'>Error in statistical
#> analysis: unused argument (g = exposure_data)
#>
#> Please check your variable selections and data format.
#>
#> character(0)
# Example 4: Comprehensive Analysis - All three analysis types
desctools(
data = histopathology,
effect_size_analysis = TRUE,
group_var = "Group",
continuous_var = "Age",
goodness_of_fit = TRUE,
normality_var = "MeasurementA",
categorical_tests = TRUE,
ordered_exposure = "Grade",
binary_outcome = "Death",
multiple_testing = "BH",
show_interpretations = TRUE
)
#>
#> ADVANCED STATISTICAL TESTS
#>
#> <div style='color: red; font-weight: bold;'>Error in statistical
#> analysis: unused argument (g = exposure_data)
#>
#> Please check your variable selections and data format.
#>
#> <div style='font-family: Arial, sans-serif;'>
#>
#> Effect Size Analysis
#>
#> Group Summary Statistics
#>
#> <table border='1' cellpadding='5' cellspacing='0'
#> style='border-collapse: collapse;'><tr style='background-color:
#> #f0f0f0; font-weight:
#> bold;'>GroupNMeanSDMinMaxControl12049.82514.4152673Treatment12848.96913.2562573
#>
#> Effect Size Results
#>
#> <table border='1' cellpadding='5' cellspacing='0'
#> style='border-collapse: collapse;'><tr style='background-color:
#> #f0f0f0; font-weight: bold;'>MeasureValueLower CIUpper
#> CIMagnitudeCohen's d0.062-0.1870.311Negligible
#>
#> Clinical Interpretation
#>
#> <div style='background-color: #f9f9f9; padding: 10px; border-left: 4px
#> solid #007acc;'>
#>
#> Effect Size Interpretation: The effect size is negligible, suggesting
#> minimal practical difference between groups.
#>
#> Cohen's Conventions:
#>
#> Small effect: d = 0.2Medium effect: d = 0.5Large effect: d = 0.8
#>
#> <div style='font-family: Arial, sans-serif;'>
#>
#> Goodness of Fit Tests
#>
#> Normality Tests
#>
#> <table border='1' cellpadding='5' cellspacing='0'
#> style='border-collapse: collapse;'><tr style='background-color:
#> #f0f0f0; font-weight:
#> bold;'>TestStatisticp-valueConclusionAnderson-DarlingInf0Non-normalJarque-Bera0.74330.6896Normal
#>
#> character(0)
# Example 5: Clinical Application - Biomarker validation
desctools(
data = BreastCancer,
effect_size_analysis = TRUE,
group_var = "Class",
continuous_var = "Cl.thickness",
hedges_correction = TRUE,
goodness_of_fit = TRUE,
normality_var = "Cell.size",
multiple_testing = "BH"
)
#>
#> ADVANCED STATISTICAL TESTS
#>
#> character(0)
#>
#> <div style='font-family: Arial, sans-serif;'>
#>
#> Effect Size Analysis
#>
#> Group Summary Statistics
#>
#> <table border='1' cellpadding='5' cellspacing='0'
#> style='border-collapse: collapse;'><tr style='background-color:
#> #f0f0f0; font-weight:
#> bold;'>GroupNMeanSDMinMaxbenign4582.9561.67418malignant2417.1952.429110
#>
#> Effect Size Results
#>
#> <table border='1' cellpadding='5' cellspacing='0'
#> style='border-collapse: collapse;'><tr style='background-color:
#> #f0f0f0; font-weight: bold;'>MeasureValueLower CIUpper
#> CIMagnitudeHedges' g-2.152-2.345-1.959Large
#>
#> Clinical Interpretation
#>
#> <div style='background-color: #f9f9f9; padding: 10px; border-left: 4px
#> solid #007acc;'>
#>
#> Effect Size Interpretation: The effect size is large and represents a
#> substantial clinical difference between groups.
#>
#> Cohen's Conventions:
#>
#> Small effect: d = 0.2Medium effect: d = 0.5Large effect: d = 0.8
#>
#> <div style='font-family: Arial, sans-serif;'>
#>
#> Goodness of Fit Tests
#>
#> Normality Tests
#>
#> <table border='1' cellpadding='5' cellspacing='0'
#> style='border-collapse: collapse;'><tr style='background-color:
#> #f0f0f0; font-weight:
#> bold;'>TestStatisticp-valueConclusionAnderson-DarlingInf0Non-normalJarque-Bera440.45380Non-normal