@dra2020/dra-analytics
v4.1.2
Published
DRA analytics
Downloads
68
Keywords
Readme
dra-analytics
This repo & package consolidates all the metrics used in DRA analytics into one place. It started as v2, because v1 was delivered by a combination repos & packages:
- district-analytics
- dra-score
- dra-graph
- compactness, and
- racial voting
The goals of this consolidation were to make the analytics code:
- More transparent -- easier to show/explain
- More maintainable -- easier to support
- More general -- easier to re-use, because the DRA-specific parts are clearly isolated & there is a CLI
Because the partisan analytics can now be calculated at a command line, independent of any tool, you can compute them for several elections, one at a time, and then generate statistics for them.
Details
This repo & package can be integrated into other tools. The libraries here are normally included like this:
import { Compactness, Equal, Graph, Minority, Partisan, Splitting } from '@dra2020/dra-analytics';
Then the various functions of the different sets are available under their appropriate symbol.
These are all the libraries:
- Compactness: Various measures of compactness.
- Equal: Population deviation & 'roughly' equal population.
- Graph: Checks for contiguity & embeddedness.
- Minority: The opportunity for minorities to elect representatives of their choice and racially polarized voting analysis.
- Partisan: Various measures of partisan bias & responsiveness, as well as support for rank-vote graphs and seats-votes curves.
- Rate: Normalization utilities as well as DRA-specific ratings.
- Splitting: County- & district-splitting and COI splitting.
Supporting types are in the Types library and supporting utilities are in the Utils library.
The analytics in DRA include metrics favored by many scholars.
A command-line interface (CLI) was added in v3.
Updates
- 12/18/21 -- Added multi-member district (MMD) support to makePopulationScorecard().
Build status for master branch
Repo contents
There are three packages that are part of this repo:
- lib: building dra-analytics.js, the production code
- cli: building dra-<command>.bundle.js, a set of command line utilities
- test: automated test code run by jest
Developing in this repo
npm install
install all dependencies
npm run build
build all bundles
npm run buildpartisan
build the partisan command
npm run buildcompactness
build the compactness command
npm run buildsplitting
build the splitting command
npm run test
run automated jest tests