npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@civiq/civic-statistics

v0.1.0

Published

Civic data statistics utilities — correlation, peer comparison, confidence scoring with civic-domain defaults

Readme

@civiq/civic-statistics

Civic data statistics utilities — correlation, peer comparison, and confidence scoring with civic-domain defaults.

Install

npm install @civiq/civic-statistics

Quick Start

import {
  correlation,
  peerComparison,
  confidenceScore,
  meetsSampleSize,
} from '@civiq/civic-statistics';

// Spearman rank correlation (default for civic data)
const result = correlation(donations, votingScores);
// { coefficient: 0.42, method: 'spearman', sampleSize: 15, meetsMinimum: true }

// Peer comparison with percentile rank
const comparison = peerComparison(0.73, peerValues, 'Senate Finance Committee');
// { value: 0.73, peerAverage: 0.61, peerCount: 12, percentileRank: 82, ... }

// Confidence scoring for insight display
const confidence = confidenceScore({
  sampleSize: 25,
  minimumSampleSize: 10,
  dataCompleteness: 0.9,
  peerCount: 15,
});
// 0.72 — show with amber indicator

// Sample size validation
meetsSampleSize(8, 'votes'); // false (minimum 10)
meetsSampleSize(5, 'trades'); // true (minimum 3)

API Reference

correlation(x, y, options?)

Compute correlation between two numeric arrays. Defaults to Spearman rank correlation (robust to non-normal distributions typical in civic data).

Returns null if arrays differ in length, have fewer than minimumSampleSize elements, or contain zero variance.

peerComparison(value, peerValues, peerGroupLabel)

Compare a value against a peer group using percentile rank. Returns null if fewer than 3 peers.

confidenceScore(factors)

Compute a confidence score (0-1) based on sample size, data completeness, and peer count. Below 0.6 = hide, 0.6-0.8 = amber, above 0.8 = green.

meetsSampleSize(actual, type)

Check if a sample size meets the minimum threshold. Types: votes (10), quarters (4), trades (3), peers (3), filings (5), recipients (3).

mean(values), sampleStandardDeviation(values)

Re-exported from simple-statistics for convenience.

Constants

| Constant | Value | Usage | | ----------------------- | ----- | ------------------------ | | MIN_VOTES_PER_SECTOR | 10 | Vote-finance correlation | | MIN_QUARTERS_TEMPORAL | 4 | Temporal analysis | | MIN_TRADES_STOCK | 3 | Stock-committee analysis | | MIN_FILINGS_LOBBYING | 5 | Lobbying pipeline | | MIN_PAC_RECIPIENTS | 3 | PAC-vote analysis | | MIN_RELEVANT_VOTES | 3 | Per-recipient PAC votes | | MIN_PEERS | 3 | Peer comparison |

Data Sources

This library provides statistical utilities for analyzing data from:

  • Congress.gov API (voting records, bill classifications)
  • FEC.gov API (campaign contributions, PAC disbursements)
  • Senate LDA API (lobbying filings)
  • House Clerk (stock trade disclosures)

License

MIT - Mark Sandford