Comprehensive robust correlation analysis with multiple correlation methods, outlier detection, diagnostic plots, and bootstrap confidence intervals. Includes Spearman, Kendall, Percentage Bend, Biweight Midcorrelation, Minimum Volume Ellipsoid (MVE), and Minimum Covariance Determinant (MCD) correlation methods.
Usage
robustcorrelation(
  data,
  dep,
  method = "spearman",
  matrix_type = "upper",
  show_pvalues = TRUE,
  sig_level = 0.05,
  p_adjust_method = "none",
  outlier_detection = FALSE,
  outlier_method = "mcd",
  outlier_threshold = 2.5,
  bootstrap_ci = FALSE,
  n_bootstrap = 1000,
  confidence_level = 0.95,
  show_heatmap = TRUE,
  heatmap_colors = "blue_white_red",
  low_color = "#3B82C5",
  mid_color = "white",
  high_color = "#E74C3C",
  show_diagnostics = FALSE,
  plot_width = 600,
  plot_height = 450,
  decimal_places = 3
)Arguments
- data
- The data as a data frame. 
- dep
- List of continuous variables for robust correlation analysis. All variables must be numeric with sufficient variation. 
- method
- Robust correlation method to use. Spearman and Kendall are rank-based, percentage bend and biweight are robust to outliers, MVE and MCD are based on robust covariance estimation. 
- matrix_type
- Display type for correlation matrix. 
- show_pvalues
- Display significance p-values in correlation matrix. 
- sig_level
- Significance level for correlation tests. 
- p_adjust_method
- Method for adjusting p-values for multiple testing. 
- outlier_detection
- Perform outlier detection analysis. 
- outlier_method
- Method for detecting outliers in the data. 
- outlier_threshold
- Threshold for outlier detection (in standard deviations or equivalent). 
- bootstrap_ci
- Calculate bootstrap confidence intervals for correlations. 
- n_bootstrap
- Number of bootstrap iterations for confidence intervals. 
- confidence_level
- Confidence level for bootstrap intervals. 
- show_heatmap
- Display correlation matrix as a heatmap visualization. 
- heatmap_colors
- Color scheme for correlation heatmap. 
- low_color
- Color for low (negative) correlation values (when using custom colors). 
- mid_color
- Color for mid (zero) correlation values (when using custom colors). 
- high_color
- Color for high (positive) correlation values (when using custom colors). 
- show_diagnostics
- Generate diagnostic plots for robust correlation analysis. 
- plot_width
- Width of plots in pixels. 
- plot_height
- Height of plots in pixels. 
- decimal_places
- Number of decimal places for correlation coefficients. 
Value
A results object containing:
| results$instructions | a html | ||||
| results$package_status | a html | ||||
| results$correlation_table | Correlation coefficients and significance tests | ||||
| results$bootstrap_table | Bootstrap confidence intervals for correlations | ||||
| results$outlier_table | Identified outliers and their statistics | ||||
| results$correlation_heatmap | an image | ||||
| results$outlier_plot | an image | ||||
| results$diagnostic_plots | an image | ||||
| results$scatterplot_matrix | an image | 
Tables can be converted to data frames with asDF or as.data.frame. For example:
results$correlation_table$asDF
as.data.frame(results$correlation_table)
Examples
# \donttest{
# Load test data
data("mtcars")
# Basic robust correlation analysis
robustcorrelation(
  data = mtcars,
  dep = c("mpg", "hp", "wt", "qsec"),
  method = "spearman"
)
# Advanced robust correlation with outlier detection
robustcorrelation(
  data = mtcars,
  dep = c("mpg", "hp", "wt", "qsec", "disp"),
  method = "percentage_bend",
  outlier_detection = TRUE,
  outlier_method = "mcd",
  bootstrap_ci = TRUE,
  n_bootstrap = 1000
)
# Multiple robust methods comparison
robustcorrelation(
  data = mtcars,
  dep = c("mpg", "hp", "wt"),
  method = "biweight",
  show_heatmap = TRUE,
  matrix_type = "lower"
)
# }