1.4.3 • Published 1 year ago

@folge3/chi-square v1.4.3

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Chi-Square

This package contains functions to calculate Chi-Square critical values as well as performing a Chi-Square statistical test.

Installation

npm install @folge3/chi-square

Usage

import {chiSquare, DistributionData, Distribution, ChiSquareTestResult, chiSquareCriticalValue, ChiSquareOptions} from "@folge3/chi-square";

const data: DistributionData = {
    rows: ['row1', 'row2'],
    columns: ['column1', 'column2'],
    data: [
        [52, 27],
        [23, 56]
    ]
}

const distribution: Distribution = new Distribution(data);

const options: ChiSquareOptions = {
    rowImpactWeightExponent: 0.3
}

// Run chi-square test with 5% uncertainty 
const result: ChiSquareTestResult = chiSquare(distribution, 0.05, options);

console.log(result);

// Get critical value for significance level 0.05 and 1 degree of freedom. 
const criticalValue = chiSquareCriticalValue(0.05, 1);

// ~3.841
console.log(criticalValue)

Options

Here are the available options for the ChiSquareOptions:

OptionTypeDescription
rowImpactWeightExponentnumberExponent modifier for weights in row impact rating. Must lie in 0.1, 1. Default: 1.
normalizeRowsbooleanFlag to decide if data shall be normalized by its rows. Takes precedence over columns.
normalizeColumnsbooleanFlag to decide if data shall be normalized by its columns. Is preceded by row normalization.
normalizationMarginalTargetnumberTarget value for marginals for normalization. Must be greater than 0. Default: 100.

Development

Testing

npm run test

Deployment

  1. Commit changes
  2. npm version patch|minor|major
  3. npm run build
  4. npm publish --access public
1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago