0.0.9 • Published 5 years ago

zigne v0.0.9

Weekly downloads
64
License
MIT
Repository
github
Last release
5 years ago

zigne

Simple utilities to calculate statistical significance and confidence intervals. Made in the context of multi-party election polling where you may want to check if the difference between two population proportions are significant.

Installation

$ npm install zigne

or

$ yarn add zigne

Usage

import zigne from 'zigne';

// Check if diff between two items change is significant

const itemLeft = zigne.item({ name: 'A', percentage: 25.8, sampleSize: 977 });
const itemRight = zigne.item({ name: 'A', percentage: 20.1, sampleSize: 980 });

const comparison = itemLeft.compare(itemRight, {
  test: 'twoTailed',
  confidenceLevel: 95,
});

comparison.significant; //=> true
comparison.marginOfError; //=> 3.12
comparison.difference; //=> -5.6...

// Compare two series

const seriesLeft = zigne.series({ sampleSize: 1000 });
const seriesRight = zigne.series({ sampleSize: 980 });

seriesLeft.add({ name: 'A', percentage: 25.8 });
seriesLeft.add({ name: 'B', percentage: 13.8 });
seriesLeft.add({ name: 'C', percentage: 2.2 });

seriesRight.add({ name: 'A', percentage: 29.8 });
seriesRight.add({ name: 'B', percentage: 11.8 });
seriesRight.add({ name: 'C', percentage: 1.2 });

const seriesComparison = seriesLeft.compare(seriesRight, {
  test: 'oneTailed',
  confidenceLevel: 95,
});

seriesComparison.A.significant; //=> true
seriesComparison.B.significant; //=> false
seriesComparison.C.significant; //=> true

Development

$ yarn install
$ yarn tdd

Credits

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago