Abstract
Statistical tests widely utilized in biostatistics, public policy, and law. Along with the well-known tests for equality of means and variances, randomness, and measures of relative variability, the package contains new robust tests of symmetry, omnibus and directional tests of normality, and their graphical counterparts such as robust QQ plot, robust trend tests for variances, etc. All implemented tests and methods are illustrated by simulations and real-life examples from legal statistics, economics, and biostatistics.
Introduction
The lawstat package (version 3.6) is a specialized toolkit designed for statisticians and researchers working at the intersection of biostatistics, public policy, and the law. It provides a robust suite of statistical tests specifically designed to handle the "messy" data often found in legal and policy research. By moving beyond standard textbook assumptions, it offers outlier-resistant methods for testing normality, randomness, and variance equality, alongside classic tools for analyzing discrimination and inequality.
The Need for Robustness in Legal and Policy Research
Standard statistical procedures—like the t-test or the classical Levene’s test—rely on strict assumptions, such as the data following a perfect normal distribution. In fields like legal statistics or public policy, data is rarely that clean; it often contains heavy tails, extreme outliers, or significant skewness.
When these assumptions are violated, standard tests can produce misleading p-values, potentially leading to incorrect conclusions in high-stakes environments like a courtroom or a legislative session. The lawstat package addresses this gap by implementing "robust" versions of these tests that remain reliable even when the data is non-normal or contaminated by outliers.
Methodological Framework
The package implements a variety of advanced statistical techniques, categorized into several key areas:
Robust Normality and Variance Analysis
Beyond the standard Shapiro-Wilk test, lawstat includes the Robust Jarque–Bera test (rjb.test) and the SJ test (sj.test), which use the Mean Absolute Deviation from the Median (MAAD) to better handle outliers. It also provides enhanced versions of Levene’s test (levene.test) for equality of variances, including options for bootstrapping and structural zero removals to improve power and stability.
Trend and Randomness
Tools like the Bartels test and the Runs test allow researchers to determine if data points are truly independent or if they exhibit underlying patterns or correlations. This is critical for time-series data or sequence analysis in policy evaluation.
Non-parametric Comparisons and Inequality Measures
The package includes the Brunner–Munzel test for comparing two samples without assuming they have the same distribution shape. Furthermore, it provides functions for calculating the Gini Index (gini.index) and plotting Lorenz Curves (lorenz.curve), which are standard metrics for assessing wealth or resource distribution.
Empirical Applications and Datasets
The package is notable for including several real-world datasets that serve as benchmarks for legal and policy analysis:
blackhire: Hiring data for eight professions and two races, used to demonstrate tests for employment discrimination.zuni: Revenue per student in New Mexico school districts, originating from the Zuni Public School v. Department of Education law case.popdata: Population data from Tennessee legislative districts (1900–1972), relevant to the landmark Baker v. Carr "one-person-one-vote" decision.bias: A dataset of surface temperature forecast errors used to illustrate randomness and trend tests.
Discussion: The Power of the Median and Visualization
Many of the "robust" tests in this package replace the sample mean with the sample median. Because the median is less affected by extreme values, the resulting tests are much more stable in the presence of outliers. The Robust QQ plot (rqq) is a standout tool; unlike a standard QQ plot that can be distorted by a few bad data points, the rqq uses robust estimators of location and scale, making it much easier to visually identify whether the bulk of the data follows a normal distribution.
Conclusion
The lawstat package successfully translates complex robust statistical theories into a user-friendly R interface. While some methods involving bootstrapping can be computationally intensive, the package provides the necessary tools for rigorous, outlier-resistant analysis required in legal and biostatistical contexts. Its focus on "stratified" analysis, such as the Cochran–Mantel–Haenszel test, further highlights its utility in proving or disproving systemic discrimination across different departments or time periods.
Summary updated