Learning Objectives:
Four Core Dimensions of Descriptive Analytics:
Measures of central tendency identify the center or typical value of a numerical distribution.
Arithmetic Mean: The arithmetic balance point of a dataset, computed by summing all values and dividing by the total count. Highly sensitive to extreme outliers.
\[\mu = \frac{\sum_{i=1}^N x_i}{N}\]
\[\bar{x} = \frac{\sum_{i=1}^n x_i}{n}\]
Median: The middle value in an ordered (ranked) array of data (\(x_{(1)} \le x_{(2)} \le \dots \le x_{(n)}\)). Resistant and robust against extreme values.
\[\text{Median} = \frac{x_{(n/2)} + x_{(n/2 + 1)}}{2}\]
Mode: The value that occurs with greatest frequency. Applicable to nominal, ordinal, interval, and ratio data. A dataset may be unimodal (one mode), bimodal (two modes), multimodal (multiple modes), or possess no mode if all observations are distinct.
Percentiles and Quartiles:
\[i = \left(\frac{P}{100}\right) \cdot n\]
\[\bar{x}_t = \frac{\sum_{i=g+1}^{n-g} x_{(i)}}{n - 2g}\]
shop_sizes <- c(190.0, 180.9, 175.0, 155.7, 154.0, 149.5, 140.8,
139.4, 139.4, 133.8, 130.1, 127.1, 125.4)
skating <- c(5.1, 5.3, 5.3, 5.5, 5.0, 5.1, 5.4, 4.2, 5.2)
calc_mode <- function(x) {
tbl <- table(x)
modes <- names(tbl)[tbl == max(tbl)]
as.numeric(modes)[1]
}
manual_mean <- sum(shop_sizes) / length(shop_sizes)
skating_sorted <- sort(skating)
g_skate <- floor(0.2 * length(skating))
manual_trim_skate <- sum(skating_sorted[(g_skate + 1):(length(skating) - g_skate)]) / (length(skating) - 2 * g_skate)
even_sample <- c(10, 14, 18, 22, 26, 30)
n_even <- length(even_sample)
even_sorted <- sort(even_sample)
manual_even_median <- (even_sorted[n_even / 2] + even_sorted[n_even / 2 + 1]) / 2
p25_idx <- (25 / 100) * length(shop_sizes)
p25_manual <- sort(shop_sizes)[ceiling(p25_idx)]
print(sprintf("Demo 3.1 sum/n = %.2f | P25 index = %.2f -> Q1 = %.2f",
manual_mean, p25_idx, p25_manual))
## [1] "Demo 3.1 sum/n = 149.32 | P25 index = 3.25 -> Q1 = 133.80"
print(sprintf("Wilcox skating g = %d | manual 20%% trimmed mean = %.2f | Even median check = %.1f",
g_skate, manual_trim_skate, manual_even_median))
## [1] "Wilcox skating g = 1 | manual 20% trimmed mean = 5.20 | Even median check = 20.0"
central_summary <- data.frame(
Dataset = c("UK Shopping Centres", "Figure Skating Ratings"),
n = c(length(shop_sizes), length(skating)),
Mean = round(c(mean(shop_sizes), mean(skating)), 2),
Median = round(c(median(shop_sizes), median(skating)), 2),
Trimmed_20 = round(c(mean(shop_sizes, trim = 0.2), mean(skating, trim = 0.2)), 2),
Mode = c(calc_mode(shop_sizes), calc_mode(skating)),
Q1 = round(c(quantile(shop_sizes, 0.25, type = 6), quantile(skating, 0.25, type = 6)), 2),
Q3 = round(c(quantile(shop_sizes, 0.75, type = 6), quantile(skating, 0.75, type = 6)), 2)
)
print(central_summary)
## Dataset n Mean Median Trimmed_20 Mode Q1 Q3
## 1 UK Shopping Centres 13 149.32 140.8 146.41 139.4 131.95 165.35
## 2 Figure Skating Ratings 9 5.12 5.2 5.20 5.1 5.05 5.35
Measures of variability quantify the dispersion, scatter, or spread of data values around their central location.
Range & Interquartile Range (\(IQR\)):
\[\text{Range} = x_{\text{max}} - x_{\text{min}}\]
\[IQR = Q_3 - Q_1\]
Population vs. Sample Variance and Standard Deviation:
\[\text{MAD} = \frac{\sum_{i=1}^n |x_i - \bar{x}|}{n}\]
\[\sigma^2 = \frac{\sum_{i=1}^N (x_i - \mu)^2}{N}\]
\[s^2 = \frac{\sum_{i=1}^n (x_i - \bar{x})^2}{n - 1} = \frac{\sum x_i^2 - \frac{(\sum x_i)^2}{n}}{n - 1}\]
\[\sigma = \sqrt{\sigma^2}, \quad s = \sqrt{s^2}\]
\[CV = \left(\frac{s}{\bar{x}}\right) \times 100\% \quad \text{or} \quad \left(\frac{\sigma}{\mu}\right) \times 100\%\]
Interpreting Standard Deviation: Chebyshev’s Theorem vs. The Empirical Rule:
\[1 - \frac{1}{k^2}\]
- For $k = 2$: At least $1 - \frac{1}{4} = 75\%$ of values lie within $\mu \pm 2\sigma$.
- For $k = 3$: At least $1 - \frac{1}{9} \approx 88.89\%$ of values lie within $\mu \pm 3\sigma$.
\[s_w^2 = \frac{\sum_{i=1}^n (W_i - \bar{W})^2}{n - 1}\]
Unlike the classical sample variance \(s^2\), \(s_w^2\) does not artificially balloon when an outlier shifts farther into the extreme tails, providing a stable foundation for robust inferential procedures.
top_15_exports <- c(312.4, 240.2, 123.7, 66.8, 53.8, 49.4, 44.5,
43.1, 42.4, 40.9, 34.8, 31.3, 30.2, 26.7, 22.2)
acc_partners <- c(88, 75, 45, 37, 24, 21)
calc_winsorized_var <- function(x, tr = 0.2) {
n <- length(x)
g <- floor(tr * n)
x_sort <- sort(x)
w <- x_sort
if (g > 0) {
w[1:g] <- x_sort[g + 1]
w[(n - g + 1):n] <- x_sort[n - g]
}
var(w)
}
pop_var <- function(x) {
sum((x - mean(x))^2) / length(x)
}
dispersion_summary <- data.frame(
Dataset = c("Top 15 US Exports ($B)", "Accounting Firm Partners"),
Mean = round(c(mean(top_15_exports), mean(acc_partners)), 2),
Range = round(c(diff(range(top_15_exports)), diff(range(acc_partners))), 2),
IQR = round(c(quantile(top_15_exports, 0.75, type = 6) - quantile(top_15_exports, 0.25, type = 6),
quantile(acc_partners, 0.75, type = 6) - quantile(acc_partners, 0.25, type = 6)), 2),
MAD = round(c(sum(abs(top_15_exports - mean(top_15_exports))) / length(top_15_exports),
sum(abs(acc_partners - mean(acc_partners))) / length(acc_partners)), 2),
Pop_Variance = round(c(pop_var(top_15_exports), pop_var(acc_partners)), 2),
Sample_Variance = round(c(var(top_15_exports), var(acc_partners)), 2),
Sample_StdDev = round(c(sd(top_15_exports), sd(acc_partners)), 2),
Winsorized_Var = round(c(calc_winsorized_var(top_15_exports), calc_winsorized_var(acc_partners)), 2),
CV_Pct = round(c((sd(top_15_exports) / mean(top_15_exports)) * 100,
(sd(acc_partners) / mean(acc_partners)) * 100), 2)
)
print(dispersion_summary)
## Dataset Mean Range IQR MAD Pop_Variance Sample_Variance
## 1 Top 15 US Exports ($B) 77.49 290.2 35.5 59.18 6795.15 7280.51
## 2 Accounting Firm Partners 48.33 67.0 55.0 22.11 627.22 752.67
## Sample_StdDev Winsorized_Var CV_Pct
## 1 85.33 202.42 110.11
## 2 27.43 545.87 56.76
chebyshev_bounds <- sapply(c(2, 3), function(k) 1 - 1 / k^2)
empirical_bounds <- sapply(c(1, 2, 3), function(k) pnorm(k) - pnorm(-k))
print(sprintf("Chebyshev min proportion (k=2, k=3): %.4f, %.4f", chebyshev_bounds[1], chebyshev_bounds[2]))
## [1] "Chebyshev min proportion (k=2, k=3): 0.7500, 0.8889"
print(sprintf("Empirical Rule normal proportion (k=1,2,3): %.4f, %.4f, %.4f",
empirical_bounds[1], empirical_bounds[2], empirical_bounds[3]))
## [1] "Empirical Rule normal proportion (k=1,2,3): 0.6827, 0.9545, 0.9973"
wilcox_p28 <- c(1, 2, 8, 9, 10, 16, 18, 22, 27, 29, 35, 42)
wilcox_p28_shifted <- c(1, 2, 8, 9, 10, 16, 18, 22, 27, 29, 35, 60)
print(sprintf("Wilcox p.28 (max=42) -> s^2 = %.2f | s_w^2 = %.2f (s_w = %.2f)",
var(wilcox_p28), calc_winsorized_var(wilcox_p28), sqrt(calc_winsorized_var(wilcox_p28))))
## [1] "Wilcox p.28 (max=42) -> s^2 = 170.57 | s_w^2 = 82.57 (s_w = 9.09)"
print(sprintf("Wilcox p.28 (max=60) -> s^2 = %.2f | s_w^2 = %.2f",
var(wilcox_p28_shifted), calc_winsorized_var(wilcox_p28_shifted)))
## [1] "Wilcox p.28 (max=60) -> s^2 = 275.30 | s_w^2 = 82.57"
When raw micro-level observations are unavailable and data are presented solely in grouped frequency distributions, class midpoints (\(M_i\)) serve as representative values for all frequencies within each interval.
\[M_i = \frac{\text{Lower Boundary}_i + \text{Upper Boundary}_i}{2}\]
\[\bar{x} = \frac{\sum_{i=1}^k f_i M_i}{n} \quad \text{where } n = \sum_{i=1}^k f_i\]
\[s^2 = \frac{\sum_{i=1}^k f_i (M_i - \bar{x})^2}{n - 1} = \frac{\sum f_i M_i^2 - \frac{(\sum f_i M_i)^2}{n}}{n - 1}, \quad s = \sqrt{s^2}\]
\[\text{Median} = L + \left[\frac{\frac{n}{2} - cf_{p}}{f_{\text{median}}}\right] \cdot w\]
where \(L\) is the lower class boundary of the median interval, \(cf_p\) is the cumulative frequency of the preceding interval, \(f_{\text{median}}\) is the frequency of the median class, and \(w\) is the class width.
[1, 3): \(M = 2, f = 4
\implies fM = 8\)[3, 5): \(M = 4, f = 12
\implies fM = 48\)[5, 7): \(M = 6, f = 13
\implies fM = 78\)[7, 9): \(M = 8, f = 19
\implies fM = 152\)[9, 11): \(M = 10, f = 7
\implies fM = 70\)[11, 13): \(M = 12, f = 5
\implies fM = 60\) \[\sum f_i = 60,
\quad \sum f_i M_i = 416 \implies \bar{x} = \frac{416}{60} =
6.93\%\] \[\sum f_i (M_i - 6.93)^2 =
427.73 \implies s^2 = \frac{427.73}{59} = 7.25 \implies s =
2.69\%\][2, 4) to
[12, 14) (\(n = 58\)):
Grouped \(\bar{x} = 7.72\), \(s^2 = 7.54\), \(\sigma = 2.72\), \(\text{Mode} = 9.00\), and Grouped \(\text{Median} = 7.7143\).calc_grouped_median <- function(lower, upper, freq) {
n_tot <- sum(freq)
cf <- cumsum(freq)
med_idx <- which(cf >= n_tot / 2)[1]
cf_prev <- ifelse(med_idx == 1, 0, cf[med_idx - 1])
w <- upper[med_idx] - lower[med_idx]
lower[med_idx] + (((n_tot / 2) - cf_prev) / freq[med_idx]) * w
}
unemp_low <- c(1, 3, 5, 7, 9, 11)
unemp_upp <- c(3, 5, 7, 9, 11, 13)
unemp_m <- (unemp_low + unemp_upp) / 2
unemp_f <- c(4, 12, 13, 19, 7, 5)
unemp_n <- sum(unemp_f)
unemp_mean <- sum(unemp_f * unemp_m) / unemp_n
unemp_var <- sum(unemp_f * (unemp_m - unemp_mean)^2) / (unemp_n - 1)
unemp_sd <- sqrt(unemp_var)
unemp_med <- calc_grouped_median(unemp_low, unemp_upp, unemp_f)
unemp_mode <- unemp_m[which.max(unemp_f)]
prob_low <- c(2, 4, 6, 8, 10, 12)
prob_upp <- c(4, 6, 8, 10, 12, 14)
prob_m <- (prob_low + prob_upp) / 2
prob_f <- c(5, 12, 14, 15, 8, 4)
prob_n <- sum(prob_f)
prob_mean <- sum(prob_f * prob_m) / prob_n
prob_var <- sum(prob_f * (prob_m - prob_mean)^2) / (prob_n - 1)
prob_sd <- sqrt(prob_var)
prob_med <- calc_grouped_median(prob_low, prob_upp, prob_f)
prob_mode <- prob_m[which.max(prob_f)]
grouped_table <- data.frame(
Dataset = c("Canadian Unemployment (Ch. 3 Slides)", "Practice Problem 32-35"),
Total_n = c(unemp_n, prob_n),
Grouped_Mean = round(c(unemp_mean, prob_mean), 4),
Grouped_Median = round(c(unemp_med, prob_med), 4),
Grouped_Mode = round(c(unemp_mode, prob_mode), 4),
Grouped_Variance = round(c(unemp_var, prob_var), 4),
Grouped_StdDev = round(c(unemp_sd, prob_sd), 4)
)
print(grouped_table)
## Dataset Total_n Grouped_Mean Grouped_Median
## 1 Canadian Unemployment (Ch. 3 Slides) 60 6.9333 7.1053
## 2 Practice Problem 32-35 58 7.7241 7.7143
## Grouped_Mode Grouped_Variance Grouped_StdDev
## 1 8 7.2497 2.6925
## 2 9 7.5366 2.7453
Distribution shape describes how observations are distributed across the measurement range relative to the central value.
Distribution Skewness:
\[S_k = \frac{3(\bar{x} - \text{Median})}{s}\]
Kurtosis: Measures the peakedness, tail heaviness, and outlier propensity of a distribution relative to a normal curve:
Tukey’s Five-Number Summary & Box-and-Whisker Plots:
Five positional anchors: \(\text{Minimum}, Q_1, \text{Median } (Q_2), Q_3, \text{Maximum}\).
Wilcox on Outlier Detection: The Masking Problem (Chapter 2, pp. 23–24):
wilcox_masking_data <- c(2, 2, 3, 3, 3, 4, 4, 4, 100000, 100000)
mean_mask <- mean(wilcox_masking_data)
sd_mask <- sd(wilcox_masking_data)
z_mask <- abs(wilcox_masking_data - mean_mask) / sd_mask
q1_m <- quantile(wilcox_masking_data, 0.25, type = 6)
q3_m <- quantile(wilcox_masking_data, 0.75, type = 6)
iqr_m <- q3_m - q1_m
upper_inner_fence_m <- q3_m + 1.5 * iqr_m
wait_times <- c(45, 52, 55, 58, 62, 65, 67, 70, 72, 75, 78, 80, 85, 120, 160)
sk_wait <- 3 * (mean(wait_times) - median(wait_times)) / sd(wait_times)
q1_w <- quantile(wait_times, 0.25, type = 6)
q3_w <- quantile(wait_times, 0.75, type = 6)
iqr_w <- q3_w - q1_w
fences_w <- c(
Lower_Outer = q1_w - 3.0 * iqr_w,
Lower_Inner = q1_w - 1.5 * iqr_w,
Upper_Inner = q3_w + 1.5 * iqr_w,
Upper_Outer = q3_w + 3.0 * iqr_w
)
print(sprintf("Wait Times Skewness S_k = %.4f", sk_wait))
## [1] "Wait Times Skewness S_k = 0.6463"
print(round(fences_w, 2))
## Lower_Outer.25% Lower_Inner.25% Upper_Inner.75% Upper_Outer.75%
## -8 25 113 146
boxplot(wait_times, horizontal = TRUE, col = "lightblue",
xlab = "Wait Time (Seconds)", main = "Box-and-Whisker Plot: Drive-Thru Wait Times")
outlier_comparison <- data.frame(
Method = c("Classic z-Score Rule (|z| >= 2)", "Tukey Boxplot Rule (Upper Inner Fence)"),
Test_Metric = c(sprintf("Max |z| = %.3f", max(z_mask)),
sprintf("Upper Fence = %.1f", upper_inner_fence_m)),
Outliers_Identified = c(
paste(wilcox_masking_data[z_mask >= 2], collapse = ", "),
paste(wilcox_masking_data[wilcox_masking_data > upper_inner_fence_m], collapse = ", ")
)
)
outlier_comparison$Outliers_Identified[outlier_comparison$Outliers_Identified == ""] <- "None (Masked)"
print(outlier_comparison)
## Method Test_Metric
## 1 Classic z-Score Rule (|z| >= 2) Max |z| = 1.897
## 2 Tukey Boxplot Rule (Upper Inner Fence) Upper Fence = 62503.4
## Outliers_Identified
## 1 None (Masked)
## 2 1e+05, 1e+05
Measures of association describe the direction and strength of linear covariation between two numeric variables.
\[s_{xy} = \frac{\sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})}{n - 1}\]
\[r = \frac{s_{xy}}{s_x s_y} = \frac{\sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum_{i=1}^n (x_i - \bar{x})^2} \sqrt{\sum_{i=1}^n (y_i - \bar{y})^2}}\]
ad_spend <- c(2, 4, 5, 6, 8, 11)
foot_traffic <- c(7, 9, 10, 13, 15, 20)
s_xy <- sum((ad_spend - mean(ad_spend)) * (foot_traffic - mean(foot_traffic))) / (length(ad_spend) - 1)
r_manual <- s_xy / (sd(ad_spend) * sd(foot_traffic))
print(sprintf("Sample Covariance s_xy = %.4f (cov = %.4f) | Manual r = %.4f",
s_xy, cov(ad_spend, foot_traffic), r_manual))
## [1] "Sample Covariance s_xy = 14.8000 (cov = 14.8000) | Manual r = 0.9918"
cor_result <- cor.test(ad_spend, foot_traffic)
plot(ad_spend, foot_traffic, pch = 19, col = "navy",
xlab = "Digital Ad Spend ($100s)", ylab = "Store Foot Traffic (100s)",
main = "Bivariate Association: Ad Spend vs. Foot Traffic")
abline(lm(foot_traffic ~ ad_spend), col = "firebrick", lwd = 2, lty = 2)
cor_summary <- data.frame(
Sample_r = round(cor_result$estimate, 4),
t_Statistic = round(cor_result$statistic, 4),
df = cor_result$parameter,
p_Value = round(cor_result$p.value, 4),
CI_Lower = round(cor_result$conf.int[1], 4),
CI_Upper = round(cor_result$conf.int[2], 4)
)
print(cor_summary)
## Sample_r t_Statistic df p_Value CI_Lower CI_Upper
## cor 0.9918 15.5431 4 1e-04 0.9241 0.9991
Following the curriculum specifications from the Course Solutions
Guide (Lesson_03_Descriptive_Statistics_Solutions.pdf),
four real-world datasets illustrate applied descriptive analysis in
R:
data/mileage.csv): Analysis of 60 passenger cars
across weight classes C1 through C6. Computes class-specific mean and
standard deviation for fuel economy (MPG) and horsepower
(HP).data/shoppers.csv): Analysis of 50 shoppers
visiting a retail store in a single day, examining positive skewness
across location, dispersion, and percentile metrics.data/pontus.csv): Evaluates ages and candidate
heights, resolving why the difference between group means differs from
the average of pairwise election differences.data/geyser.csv): Compares eruption intervals
across two consecutive weeks (WEEK1 and
WEEK2), highlighting temporal consistency and marked
bimodality.mileage_df <- read.csv("https://raw.githubusercontent.com/telpirion/CumulativeStudyGuide/refs/heads/main/data/mileage.csv")
shoppers_df <- read.csv("https://raw.githubusercontent.com/telpirion/CumulativeStudyGuide/refs/heads/main/data/shoppers.csv")
pontus_df <- read.csv("https://raw.githubusercontent.com/telpirion/CumulativeStudyGuide/refs/heads/main/data/pontus.csv")
geyser_df <- read.csv("https://raw.githubusercontent.com/telpirion/CumulativeStudyGuide/refs/heads/main/data/geyser.csv")
mpg_mean <- aggregate(MPG ~ CLASS, data = mileage_df, mean)
mpg_sd <- aggregate(MPG ~ CLASS, data = mileage_df, sd)
hp_mean <- aggregate(HP ~ CLASS, data = mileage_df, mean)
hp_sd <- aggregate(HP ~ CLASS, data = mileage_df, sd)
mileage_analysis <- data.frame(
CLASS = mpg_mean$CLASS,
Mean_MPG = round(mpg_mean$MPG, 2),
SD_MPG = round(mpg_sd$MPG, 2),
Mean_HP = round(hp_mean$HP, 2),
SD_HP = round(hp_sd$HP, 2)
)
print(mileage_analysis)
## CLASS Mean_MPG SD_MPG Mean_HP SD_HP
## 1 C1 39.68 1.36 89.22 7.05
## 2 C2 35.55 0.53 92.00 9.09
## 3 C3 32.02 0.63 103.50 12.77
## 4 C4 29.66 2.11 123.83 25.67
## 5 C5 23.85 0.77 171.58 45.35
## 6 C6 19.19 2.70 224.71 74.02
calc_range <- function(x) { max(x, na.rm = TRUE) - min(x, na.rm = TRUE) }
summary_stats <- function(x) {
data.frame(
Value = c(
mean(x, na.rm = TRUE),
median(x, na.rm = TRUE),
calc_range(x),
sd(x, na.rm = TRUE),
var(x, na.rm = TRUE),
quantile(x, probs = 0.25, na.rm = TRUE),
quantile(x, probs = 0.75, na.rm = TRUE),
quantile(x, probs = 0.10, na.rm = TRUE)
),
row.names = c("Mean", "Median", "Range", "StdDev", "Var", "Q1", "Q3", "P10")
)
}
shoppers_summary <- round(summary_stats(shoppers_df$Spending), 2)
print(shoppers_summary)
## Value
## Mean 25.44
## Median 20.74
## Range 61.53
## StdDev 15.21
## Var 231.33
## Q1 14.39
## Q3 33.66
## P10 10.18
pontus_pres_age <- round(summary_stats(pontus_df$Age), 2)
print(pontus_pres_age)
## Value
## Mean 54.76
## Median 54.50
## Range 27.00
## StdDev 6.56
## Var 43.05
## Q1 51.00
## Q3 57.75
## P10 46.70
diff_ht <- pontus_df$Ht - pontus_df$HtOpp
boxplot(diff_ht, horizontal = TRUE, col = "darkseagreen",
xlab = "Height Difference (President - Opponent, cm)",
main = "Boxplot of Presidential Height Differences")
geyser_comp <- round(apply(geyser_df, 2, summary), 2)
print(geyser_comp)
## WEEK1 WEEK2
## Min. 43.00 45.00
## 1st Qu. 58.75 63.25
## Median 75.00 76.00
## Mean 71.62 72.76
## 3rd Qu. 82.00 81.25
## Max. 108.00 94.00
boxplot(geyser_df$WEEK1, geyser_df$WEEK2, names = c("Week 1", "Week 2"),
horizontal = TRUE, col = c("lightcyan", "mistyrose"),
xlab = "Interval (Minutes)", main = "Boxplots of Geyser Eruption Intervals by Week")
| Descriptive Dimension | Metric / Tool | Mathematical Definition / Formula | Distributional Properties | R Function |
|---|---|---|---|---|
| Central Location | Arithmetic Mean (\(\bar{x}\)) | \(\bar{x} = \frac{\sum x_i}{n}\) | Highly sensitive to outliers & skewness | mean(x) |
| Central Location | Median | Middle value in ordered array (\(x_{(n/2)}\) average) | Robust / resistant to extreme values | median(x) |
| Central Location | Mode | Value with greatest absolute frequency | Unaffected by outliers; applies to all data levels | table(x) |
| Robust Location | 20% Trimmed Mean (\(\bar{x}_t\)) | \(\bar{x}_t = \frac{\sum x_{(i)}}{n - 2g}, \; g = \lfloor 0.2n \rfloor\) | Balances outlier resistance and statistical efficiency | mean(x, trim = 0.2) |
| Relative Location | Percentiles / Quartiles | Location \(i = \left(\frac{P}{100}\right) \cdot n\); \(IQR = Q_3 - Q_1\) | Positional; robust against extreme values | quantile(x, probs, type = 6) |
| Variability | Sample Variance (\(s^2\)) | \(s^2 = \frac{\sum (x_i - \bar{x})^2}{n - 1}\) | Unbiased estimator using Bessel’s \(n-1\) correction | var(x) |
| Variability | Standard Deviation (\(s\)) | \(s = \sqrt{s^2}\) | Original data units; sensitive to outliers | sd(x) |
| Robust Dispersion | Winsorized Variance (\(s_w^2\)) | \(s_w^2 = \frac{\sum (W_i - \bar{W})^2}{n - 1}\) | Resists outlier inflation in extreme tails | Custom calc_winsorized_var() |
| Relative Spread | Coefficient of Variation (\(CV\)) | \(CV = \left(\frac{s}{\bar{x}}\right) \times 100\%\) | Normalized dispersion; requires ratio scale data | (sd(x) / mean(x)) * 100 |
| Grouped Analytics | Grouped Mean & Variance | \(\bar{x} = \frac{\sum f_i M_i}{n}, \; s^2 = \frac{\sum f_i(M_i - \bar{x})^2}{n-1}\) | Approximates ungrouped parameters from midpoints | Formulaic / cut(),
table() |
| Dispersion Bound | Chebyshev’s Theorem | At least \(1 - 1/k^2\) within \(\mu \pm k\sigma\) | Distribution-free; holds for any dataset (\(k > 1\)) | N/A (formulaic) |
| Mound-Shaped Spread | Empirical Rule | \(68\%\) (\(1\sigma\)), \(95\%\) (\(2\sigma\)), \(99.7\%\) (\(3\sigma\)) | Requires symmetrical, bell-shaped distribution | pnorm(), qnorm() |
| Outlier Detection | Tukey’s Fences | Inner: \(Q_{1,3} \pm 1.5(IQR)\); Outer: \(Q_{1,3} \pm 3.0(IQR)\) | Robust; prevents masking of extreme values | boxplot(x, horizontal = TRUE) |
| Bivariate Association | Pearson’s Correlation (\(r\)) | \(r = \frac{\sum (x - \bar{x})(y - \bar{y})}{\sqrt{\sum (x - \bar{x})^2 \sum (y - \bar{y})^2}}\) | Measures linear association; sensitive to outliers | cor(x, y),
cor.test(x, y) |