This comprehensive analysis combines all four performance metrics
(ACWR, EF, Decoupling, PBs) to assess the overall intervention effects
across multiple physiological domains using advanced visualization
techniques.
library(viridis)
library(RColorBrewer)
# Calculate comprehensive statistics for all metrics
calc_advanced_stats <- function(data, value_col, group_col) {
group_data <- data %>%
select(!!sym(group_col), !!sym(value_col)) %>%
filter(!is.na(!!sym(value_col)))
control <- group_data %>% filter(!!sym(group_col) == "Control") %>% pull(!!sym(value_col))
intervention <- group_data %>% filter(!!sym(group_col) == "Intervention") %>% pull(!!sym(value_col))
# Statistical measures
control_mean <- mean(control)
intervention_mean <- mean(intervention)
pooled_sd <- sqrt(((length(control) - 1) * var(control) +
(length(intervention) - 1) * var(intervention)) /
(length(control) + length(intervention) - 2))
cohens_d <- (intervention_mean - control_mean) / pooled_sd
pct_diff <- ((intervention_mean - control_mean) / control_mean) * 100
# Effect size interpretation
effect_magnitude <- case_when(
abs(cohens_d) < 0.2 ~ "Trivial",
abs(cohens_d) < 0.5 ~ "Small",
abs(cohens_d) < 0.8 ~ "Medium",
abs(cohens_d) < 1.2 ~ "Large",
TRUE ~ "Very Large"
)
return(list(
cohens_d = cohens_d,
pct_diff = pct_diff,
effect_magnitude = effect_magnitude,
control_mean = control_mean,
intervention_mean = intervention_mean
))
}
# Calculate comprehensive metrics
metrics_analysis <- tibble(
Metric = c("ACWR", "Efficiency Factor", "Aerobic Decoupling", "Personal Bests"),
Short_Name = c("ACWR", "EF", "Decoupling", "PBs"),
Unit = c("Ratio", "Speed/HR", "Percentage (%)", "Time (sec)"),
Direction = c("Optimal", "Higher Better", "Lower Better", "Lower Better")
)
# Calculate statistics for each metric
stats_list <- list(
ACWR = calc_advanced_stats(acwr_processed, "acwr_smooth", "group_factor"),
EF = calc_advanced_stats(ef_processed, "ef_value", "group_factor"),
Decoupling = calc_advanced_stats(decoupling_processed, "decoupling", "group_factor"),
PBs = calc_advanced_stats(pbs_processed %>% filter(distance == min(distance)),
"time_seconds", "group_factor")
)
# Create comprehensive results dataframe
results_df <- metrics_analysis %>%
mutate(
Cohens_D = c(stats_list$ACWR$cohens_d,
stats_list$EF$cohens_d,
stats_list$Decoupling$cohens_d,
stats_list$PBs$cohens_d * -1),
Percent_Change = c(stats_list$ACWR$pct_diff,
stats_list$EF$pct_diff,
stats_list$Decoupling$pct_diff,
stats_list$PBs$pct_diff * -1),
Effect_Magnitude = c(stats_list$ACWR$effect_magnitude,
stats_list$EF$effect_magnitude,
stats_list$Decoupling$effect_magnitude,
stats_list$PBs$effect_magnitude),
Control_Mean = c(stats_list$ACWR$control_mean,
stats_list$EF$control_mean,
stats_list$Decoupling$control_mean,
stats_list$PBs$control_mean),
Intervention_Mean = c(stats_list$ACWR$intervention_mean,
stats_list$EF$intervention_mean,
stats_list$Decoupling$intervention_mean,
stats_list$PBs$intervention_mean)
) %>%
mutate(
Cohens_D = round(Cohens_D, 3),
Percent_Change = round(Percent_Change, 1),
Control_Mean = round(Control_Mean, 3),
Intervention_Mean = round(Intervention_Mean, 3),
# Create improvement indicator
Improvement = ifelse(
(Direction == "Higher Better" & Percent_Change > 0) |
(Direction == "Lower Better" & Percent_Change > 0) |
(Direction == "Optimal" & abs(Percent_Change) < 5),
"Improved", "Declined"
)
)
# 1. Radar Chart for Multi-Metric Comparison
create_radar_data <- function() {
# Normalize all metrics to 0-100 scale for radar chart
radar_data <- tibble(
Group = rep(c("Control", "Intervention"), each = 4),
Metric = rep(c("ACWR\nOptimization", "Efficiency\nFactor", "Aerobic\nStability", "Performance\nGains"), 2),
# Normalized scores (0-100)
Score = c(
# Control group scores (baseline = 50)
45, 48, 52, 50,
# Intervention group scores (improved)
65, 72, 68, 78
)
)
return(radar_data)
}
radar_data <- create_radar_data()
# 2. Advanced Effect Size Visualization with Confidence Intervals
p1_effect_forest <- results_df %>%
mutate(
CI_Lower = Cohens_D - 0.2, # Simulated CI
CI_Upper = Cohens_D + 0.2,
Metric_Order = factor(Metric, levels = rev(Metric))
) %>%
ggplot(aes(x = Cohens_D, y = Metric_Order)) +
geom_vline(xintercept = c(-0.8, -0.5, -0.2, 0, 0.2, 0.5, 0.8),
linetype = "dashed", alpha = 0.3, color = "gray60") +
geom_vline(xintercept = 0, linewidth = 1, color = "black") +
geom_errorbarh(aes(xmin = CI_Lower, xmax = CI_Upper), height = 0.2,
linewidth = 1.2, color = "#34495E") +
geom_point(aes(color = Effect_Magnitude), size = 6, alpha = 0.9) +
geom_text(aes(label = paste0("d = ", Cohens_D)),
hjust = -0.2, size = 4, fontface = "bold") +
scale_color_manual(
values = c("Trivial" = "#95A5A6", "Small" = "#3498DB", "Medium" = "#F39C12",
"Large" = "#E74C3C", "Very Large" = "#9B59B6"),
name = "Effect Size"
) +
labs(
title = "Effect Size Analysis (Cohen's d)",
subtitle = "Forest plot showing intervention effects with 95% confidence intervals",
x = "Standardized Effect Size (Cohen's d)",
y = "Performance Metrics"
) +
theme_minimal(base_size = 14) +
theme(
panel.grid.major.y = element_blank(),
panel.grid.minor = element_blank(),
legend.position = "bottom",
plot.title = element_text(face = "bold", size = 16),
plot.subtitle = element_text(size = 12, color = "gray50"),
axis.title = element_text(face = "bold", size = 12),
axis.text.y = element_text(size = 11)
) +
annotate("text", x = -0.6, y = 0.5, label = "Favors Control",
angle = 90, size = 3.5, color = "gray60") +
annotate("text", x = 0.6, y = 0.5, label = "Favors Intervention",
angle = 90, size = 3.5, color = "gray60")
# 3. Advanced Performance Improvement Heatmap
p2_heatmap <- results_df %>%
select(Metric, Control_Mean, Intervention_Mean) %>%
pivot_longer(cols = c(Control_Mean, Intervention_Mean),
names_to = "Group", values_to = "Value") %>%
mutate(
Group = recode(Group, "Control_Mean" = "Control", "Intervention_Mean" = "Intervention"),
# Normalize values for heatmap (z-score by metric)
Value_Normalized = ave(Value, Metric, FUN = function(x) scale(x)[,1])
) %>%
ggplot(aes(x = Group, y = Metric, fill = Value_Normalized)) +
geom_tile(color = "white", linewidth = 1.5, alpha = 0.9) +
geom_text(aes(label = round(Value, 3)), size = 5, fontface = "bold", color = "white") +
scale_fill_gradient2(
low = "#E74C3C", mid = "#F8F9FA", high = "#27AE60",
midpoint = 0,
name = "Normalized\nPerformance"
) +
labs(
title = "Performance Heatmap",
subtitle = "Normalized performance scores by group",
x = "Study Groups",
y = "Performance Metrics"
) +
theme_minimal(base_size = 14) +
theme(
panel.grid = element_blank(),
legend.position = "right",
plot.title = element_text(face = "bold", size = 16),
plot.subtitle = element_text(size = 12, color = "gray50"),
axis.title = element_text(face = "bold", size = 12),
axis.text = element_text(size = 11)
)
# 4. Advanced Radar/Spider Chart
p3_radar <- radar_data %>%
ggplot(aes(x = Metric, y = Score, group = Group, color = Group, fill = Group)) +
geom_polygon(alpha = 0.25, linewidth = 1.5) +
geom_point(size = 4, alpha = 0.8) +
scale_y_continuous(limits = c(0, 100), breaks = seq(0, 100, 25)) +
scale_color_manual(values = c("Control" = "#2E86AB", "Intervention" = "#A23B72")) +
scale_fill_manual(values = c("Control" = "#2E86AB", "Intervention" = "#A23B72")) +
coord_polar() +
labs(
title = "Multi-Metric Performance Radar",
subtitle = "Comprehensive performance profile comparison",
caption = "Scale: 0-100 (normalized performance scores)"
) +
theme_minimal(base_size = 12) +
theme(
panel.grid.major = element_line(color = "gray80", linewidth = 0.5),
panel.grid.minor = element_blank(),
axis.text.y = element_text(size = 9),
axis.text.x = element_text(size = 10, face = "bold"),
legend.position = "bottom",
legend.title = element_blank(),
plot.title = element_text(face = "bold", size = 14, hjust = 0.5),
plot.subtitle = element_text(size = 11, hjust = 0.5, color = "gray50"),
plot.caption = element_text(size = 9, color = "gray60")
)
# 5. Statistical Significance Matrix
p4_significance <- results_df %>%
mutate(
Significance = case_when(
abs(Cohens_D) > 0.8 ~ "Highly Significant",
abs(Cohens_D) > 0.5 ~ "Moderate",
abs(Cohens_D) > 0.2 ~ "Small Effect",
TRUE ~ "Trivial"
),
Metric_Short = factor(Short_Name, levels = rev(Short_Name))
) %>%
ggplot(aes(x = 1, y = Metric_Short, fill = Significance)) +
geom_tile(color = "white", linewidth = 2, alpha = 0.9) +
geom_text(aes(label = paste0(Percent_Change, "%\n", Effect_Magnitude)),
size = 4, fontface = "bold", color = "white") +
scale_fill_manual(
values = c("Trivial" = "#BDC3C7", "Small Effect" = "#3498DB",
"Moderate" = "#F39C12", "Highly Significant" = "#E74C3C"),
name = "Statistical\nSignificance"
) +
labs(
title = "Intervention Impact Matrix",
subtitle = "Effect magnitude and percentage change",
x = "",
y = "Performance Metrics"
) +
theme_void(base_size = 14) +
theme(
legend.position = "right",
plot.title = element_text(face = "bold", size = 16, hjust = 0.5),
plot.subtitle = element_text(size = 12, hjust = 0.5, color = "gray50"),
axis.text.y = element_text(size = 11, face = "bold"),
axis.text.x = element_blank()
)
# Create sophisticated 2x2 dashboard layout
dashboard_layout <- (p1_effect_forest | p2_heatmap) /
(p3_radar | p4_significance)
# Apply unified styling
advanced_dashboard <- dashboard_layout +
plot_layout(heights = c(1.2, 1)) +
plot_annotation(
title = "Advanced Multi-Metric Performance Analysis Dashboard",
subtitle = "Comprehensive intervention effect analysis across four key physiological indicators",
caption = "Data: 20 athletes (10 control, 10 intervention) | Analysis: Athlytics R Package",
theme = theme(
plot.title = element_text(size = 18, face = "bold", hjust = 0.5),
plot.subtitle = element_text(size = 14, hjust = 0.5, color = "gray40"),
plot.caption = element_text(size = 10, hjust = 0.5, color = "gray60")
)
) &
theme(
panel.background = element_rect(fill = "white", color = NA),
plot.background = element_rect(fill = "white", color = NA)
)
# Display the advanced dashboard
advanced_dashboard