{"_id":"@civiq/civic-statistics","_rev":"3-8be40ad8ba2920582b2d6a907a92cd65","name":"@civiq/civic-statistics","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@civiq/civic-statistics","version":"0.1.0","keywords":["civic","statistics","correlation","government","civic-tech"],"author":{"name":"Mark Sandford"},"license":"MIT","_id":"@civiq/civic-statistics@0.1.0","maintainers":[{"name":"civdotiq","email":"contact@civdotiq.org"}],"homepage":"https://github.com/civiq/civic-statistics#readme","bugs":{"url":"https://github.com/civiq/civic-statistics/issues"},"dist":{"shasum":"99ca0f1a6cd26193296097e8cacd348136be7f7d","tarball":"https://registry.npmjs.org/@civiq/civic-statistics/-/civic-statistics-0.1.0.tgz","fileCount":19,"integrity":"sha512-Mkfad+IiEBL1DfU/0ml75Jr2JSp/bIMRW3vOz7FCiJEVXqaO3DWHRllZUJsp8HG0yZdpBPJe3gy3F6P10+A9Sw==","signatures":[{"sig":"MEYCIQDFZ7+SGbY++Y+MjyKHlqP9vFMuz3NNi49ftI/OvuFQ3wIhAJqIVc8jtPCSdijXiU/PHWmKMICri6yEW1r/72PbgdS/","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38546},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"0746f27bbf260834f24c96a94e92a9fff8512159","scripts":{"test":"vitest run","build":"tsc","clean":"rm -rf dist"},"_npmUser":{"name":"civdotiq","email":"contact@civdotiq.org"},"repository":{"url":"git+https://github.com/civiq/civic-statistics.git","type":"git"},"_npmVersion":"11.6.2","description":"Civic data statistics utilities — correlation, peer comparison, confidence scoring with civic-domain defaults","directories":{},"_nodeVersion":"25.2.1","dependencies":{"simple-statistics":"^7.8.0"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.0"},"_npmOperationalInternal":{"tmp":"tmp/civic-statistics_0.1.0_1774446465499_0.6327461863007522","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@civiq/civic-statistics","version":"0.1.1","keywords":["civic","statistics","correlation","government","civic-tech","civiq","peer-comparison","confidence-score"],"author":{"name":"Mark Sandford"},"license":"MIT","_id":"@civiq/civic-statistics@0.1.1","maintainers":[{"name":"civdotiq","email":"contact@civdotiq.org"}],"homepage":"https://github.com/civdotiq/civ.iq/tree/main/packages/civic-statistics#readme","bugs":{"url":"https://github.com/civdotiq/civ.iq/issues"},"dist":{"shasum":"48d48a484eb7dfb65dd7e4aa7d5df4e5e4d1b095","tarball":"https://registry.npmjs.org/@civiq/civic-statistics/-/civic-statistics-0.1.1.tgz","fileCount":21,"integrity":"sha512-TcGJ62t/lDXCPTDMxf5Yf/nbXGBvPkpsvKxRFlHw0jKN+1YzvKt5LuTPdWxeI772DJb/YwxDsYVbjh0npQEtzg==","signatures":[{"sig":"MEQCIAEO0+Zol1E5fxDl4VOpkUcEE5kVl3tyFnrBUnGZzEIpAiAdqN+4cKLIEpvW1BP9/CvZuHiCvPkiW5vwdT4LPQPSIA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@civiq%2fcivic-statistics@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":43919},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=20.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"aab844faa91aa45621a51e2844c6e43db51a577a","scripts":{"test":"vitest run","build":"tsc","clean":"rm -rf dist","prepublishOnly":"npm run clean && npm run build && npm run test"},"_npmUser":{"name":"civdotiq","email":"contact@civdotiq.org"},"repository":{"url":"git+https://github.com/civdotiq/civ.iq.git","type":"git","directory":"packages/civic-statistics"},"_npmVersion":"10.9.7","description":"Civic data statistics utilities — correlation, peer comparison, confidence scoring with civic-domain defaults","directories":{},"sideEffects":false,"_nodeVersion":"22.22.2","dependencies":{"simple-statistics":"^7.8.0"},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.8.0"},"_npmOperationalInternal":{"tmp":"tmp/civic-statistics_0.1.1_1776451331330_0.8131602266997562","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@civiq/civic-statistics","version":"0.1.2","description":"Civic data statistics utilities — correlation, peer comparison, confidence scoring with civic-domain defaults","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"sideEffects":false,"scripts":{"build":"tsc","test":"vitest run","clean":"rm -rf dist","prepublishOnly":"npm run clean && npm run build && npm run test"},"dependencies":{"simple-statistics":"^7.8.0"},"devDependencies":{"typescript":"^5.8.0"},"license":"MIT","author":{"name":"Mark Sandford"},"homepage":"https://github.com/civdotiq/civ.iq/tree/main/packages/civic-statistics#readme","bugs":{"url":"https://github.com/civdotiq/civ.iq/issues"},"repository":{"type":"git","url":"git+https://github.com/civdotiq/civ.iq.git","directory":"packages/civic-statistics"},"publishConfig":{"access":"public","provenance":true},"engines":{"node":">=20.0.0"},"keywords":["civic","statistics","correlation","government","civic-tech","civiq","peer-comparison","confidence-score"],"_id":"@civiq/civic-statistics@0.1.2","gitHead":"b8b3b3e170b76d778df04e5a35096e1c42c4c539","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-kttIoGbHW5CPDcf1xMed3hAdQPYBUNvIIn7j9fgUafPJsdYBJpX5nWFGAqUsT2VoQkjal14TtcektG7iUvgFSw==","shasum":"b83ffabe0055ad5772070897576c355711858c8e","tarball":"https://registry.npmjs.org/@civiq/civic-statistics/-/civic-statistics-0.1.2.tgz","fileCount":21,"unpackedSize":44455,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@civiq%2fcivic-statistics@0.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDIEJi8/gdmEGD4v0zXNZsxlMnPIDVoeMWSG3oDxPMgRAiB7YUpdvnR5bNca96TwJm7wdw0QS+jQcHotmbwhW21pYA=="}]},"_npmUser":{"name":"civdotiq","email":"contact@civdotiq.org"},"directories":{},"maintainers":[{"name":"civdotiq","email":"contact@civdotiq.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/civic-statistics_0.1.2_1776454375777_0.02963583580814455"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-25T13:47:45.384Z","modified":"2026-04-17T19:32:56.286Z","0.1.0":"2026-03-25T13:47:45.643Z","0.1.1":"2026-04-17T18:42:11.485Z","0.1.2":"2026-04-17T19:32:55.948Z"},"bugs":{"url":"https://github.com/civdotiq/civ.iq/issues"},"author":{"name":"Mark Sandford"},"license":"MIT","homepage":"https://github.com/civdotiq/civ.iq/tree/main/packages/civic-statistics#readme","keywords":["civic","statistics","correlation","government","civic-tech","civiq","peer-comparison","confidence-score"],"repository":{"type":"git","url":"git+https://github.com/civdotiq/civ.iq.git","directory":"packages/civic-statistics"},"description":"Civic data statistics utilities — correlation, peer comparison, confidence scoring with civic-domain defaults","maintainers":[{"name":"civdotiq","email":"contact@civdotiq.org"}],"readme":"# @civiq/civic-statistics\n\nCivic data statistics utilities — correlation, peer comparison, and confidence scoring with civic-domain defaults.\n\n## Install\n\n```bash\nnpm install @civiq/civic-statistics\n```\n\n## Quick Start\n\n```typescript\nimport {\n  correlation,\n  peerComparison,\n  confidenceScore,\n  meetsSampleSize,\n} from '@civiq/civic-statistics';\n\n// Spearman rank correlation (default for civic data)\nconst result = correlation(donations, votingScores);\n// { coefficient: 0.42, method: 'spearman', sampleSize: 15, meetsMinimum: true }\n\n// Peer comparison with percentile rank\nconst comparison = peerComparison(0.73, peerValues, 'Senate Finance Committee');\n// { value: 0.73, peerAverage: 0.61, peerCount: 12, percentileRank: 82, ... }\n\n// Confidence scoring for insight display\nconst confidence = confidenceScore({\n  sampleSize: 25,\n  minimumSampleSize: 10,\n  dataCompleteness: 0.9,\n  peerCount: 15,\n});\n// 0.72 — show with amber indicator\n\n// Sample size validation\nmeetsSampleSize(8, 'votes'); // false (minimum 10)\nmeetsSampleSize(5, 'trades'); // true (minimum 3)\n```\n\n## API Reference\n\n### `correlation(x, y, options?)`\n\nCompute correlation between two numeric arrays. Defaults to Spearman rank correlation (robust to non-normal distributions typical in civic data).\n\nReturns `null` if arrays differ in length, have fewer than `minimumSampleSize` elements, or contain zero variance.\n\n### `peerComparison(value, peerValues, peerGroupLabel)`\n\nCompare a value against a peer group using percentile rank. Returns `null` if fewer than 3 peers.\n\n### `confidenceScore(factors)`\n\nCompute 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.\n\n### `meetsSampleSize(actual, type)`\n\nCheck if a sample size meets the minimum threshold. Types: `votes` (10), `quarters` (4), `trades` (3), `peers` (3), `filings` (5), `recipients` (3).\n\n### `mean(values)`, `sampleStandardDeviation(values)`\n\nRe-exported from `simple-statistics` for convenience.\n\n## Constants\n\n| Constant                | Value | Usage                    |\n| ----------------------- | ----- | ------------------------ |\n| `MIN_VOTES_PER_SECTOR`  | 10    | Vote-finance correlation |\n| `MIN_QUARTERS_TEMPORAL` | 4     | Temporal analysis        |\n| `MIN_TRADES_STOCK`      | 3     | Stock-committee analysis |\n| `MIN_FILINGS_LOBBYING`  | 5     | Lobbying pipeline        |\n| `MIN_PAC_RECIPIENTS`    | 3     | PAC-vote analysis        |\n| `MIN_RELEVANT_VOTES`    | 3     | Per-recipient PAC votes  |\n| `MIN_PEERS`             | 3     | Peer comparison          |\n\n## Data Sources\n\nThis library provides statistical utilities for analyzing data from:\n\n- Congress.gov API (voting records, bill classifications)\n- FEC.gov API (campaign contributions, PAC disbursements)\n- Senate LDA API (lobbying filings)\n- House Clerk (stock trade disclosures)\n\n## License\n\nMIT - Mark Sandford\n","readmeFilename":"README.md"}