As we have seen, when the data follows the typical normality assumption and the data does not deviate in drastic ways, we can often rely on parametric methods. However, what happens when we can’t follow these assumptions? What happens when we have something that looks like this:
set.seed(42)
peak1 <- rnorm(n = 500, mean = 10, sd = 2)
peak2 <- rnorm(n = 500, mean = 20, sd = 2)
bimodal_dist <- data.frame(peaks = c(peak1, peak2))
ggplot(bimodal_dist, aes(x=peaks)) +
geom_histogram(
color = "black",
fill = "lightblue",
bins = 30,
position = "dodge"
) +
labs(
title = "Histogram with Bimodal Distribution Curve",
x = "Value"
) +
theme_minimal()
What if we have a sample that’s too small to use the Central Limit Theorem? Or, even one that has too many outliers to the point that it affects the distribution/parameters (and can not be removed so easily)?
Nonparametric Statistics
Nonparametric statistics are essentially methods in which we do not assume that the data follows a specific probability distribution, and that the models can not be determined by some parameters. Nonparametric statistics methods often work around the complications in the previous slide by using ranks, medians, or frequencies. In other words, if the data:
- is heavily skewed or bimodal
- has a very small sample size (n < 30)
- can not be determined by usual parameters (ex. mean)
Then, we would use nonparametric statistics.
Examples of Nonparametric Statistics
- Wilcoxon signed-rank test
- Nonparametric Regression
- Kernel Density Estimation: \[f_h(x) = \frac{1}{nh} \sum_{i=1}^{n} K\left(\frac{x - x_i}{h}\right)\]
p <- ggplot(iris, aes(x = Sepal.Length, fill = Species)) +
geom_density(alpha = 0.5) +
labs(
title = "KDE Visual Example via ggplotly using iris dataset",
x = "Sepal Length",
y = "Density") +
theme_minimal()
ggplotly(p)
Why use Nonparametric Statistics?
So, if there is anything to take away from this. The advantages of using nonparametric statistics would be:
- Flexibility: requires fewer assumptions on the data
- Robustness: not as impacted by outliers
- Power: requires a smaller sample size
- Useful: if typical distributions fail, we can fall back on nonparametreic methods instead