Header-only C++ statistics for checking qualitative coding: classification metrics from a confusion matrix (precision, recall, accuracy, kappa, ...), hypergeometric intervals and perfect-sample sizes, metric derivation from any two known metrics, bootstrap comparison of two coders, and Shaffer's rho (ported from rhoR). It is the code shared by qestats (R), qe-stats (Python), QEStats.jl (Julia) and libqe-stats-wasm (JavaScript).
Everything is in namespace qestats. It needs only the C++ standard library.
Install
Add the qe-libs Conan remote and require libqe-stats. Available versions are listed on the registry page.
conan remote add qe-libs https://gitlab.com/api/v4/projects/22522458/packages/conan
find_package(libqe-stats REQUIRED)
target_link_libraries(app PRIVATE libqe-stats::libqe-stats)
Modules
| Header | Contents |
| metrics.hpp | qestats::ConfusionMatrix, qestats::Metrics, qestats::kappa_from_counts and qestats::calculate_metrics / qestats::metrics_from_cm; qestats::get_metric by name |
| inference.hpp | Hypergeometric CDF and intervals (qestats::phyper, qestats::hyper_range), perfect-sample sizes (qestats::ps_proportion, qestats::ps_est_proportion) and qestats::metrics_range |
| derivation.hpp | The 22-row formula table: qestats::range (a metric's min/max given two others) and qestats::derive / qestats::derive_from_rates (the full confusion matrix from three metrics) |
| comparison.hpp | Bootstrap metric intervals (qestats::bootstrap_metrics), comparing two coders (qestats::p_diff, qestats::n_diff, qestats::N_Diff2, qestats::range_est) and perfect-sample sizes for kappa (qestats::ps_kappa, qestats::ps_est_kappa) |
| rho.hpp | Shaffer's rho: qestats::rho with rhoR's two methods (qestats::RhoMethod), their building blocks in qestats::rho_standard / qestats::rho_fast, and qestats::StdRng; plug in R's generator to reproduce rhoR's seeded results |
| qestats.hpp | Includes every module |
Source
libqe-stats on GitLab — the headers are in include/qestats/, the R package in R/, the Python package in python/, the Julia package in julia/, the WebAssembly build in wasm/.