Coder Social home page Coder Social logo

anova's Introduction

anova

NPM version build status Test coverage npm download

Analysis of variance (ANOVA).

Installation

$ npm i ml-anova

Usage

One-way ANOVA

import { oneWay } from 'ml-anova';

const data = [6, 8, 4, 5, 3, 4, 8, 12, 9, 11, 6, 8, 13, 9, 11, 8, 7, 12];
const classes = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2];

const result = oneWay(data, classes, { alpha: 0.05 }); // 0.05 is the default value for the alpha option
/*
  {
    rejected: true, // The null hypothesis has been rejected at the 5% significance level.
    pValue: 0.0023987773293929083,
    testValue: 9.264705882352942,
    freedom: [2, 15]
  }
*/

Repeated measures ANOVA

import {repeatedMeasures} from 'ml-anova';

const d = [45, 50, 55, 42, 42, 45, 36, 41, 43, 39, 35, 40, 51, 55, 59, 44, 49, 56];
const patients = [1 ,1 ,1 ,2 ,2 ,2 ,3 ,3 ,3 ,4, 4, 4, 5,5 ,5 ,6 ,6 ,6 ];
const time = [
  'pre','3month','6months','pre','3month','6months','pre','3month','6months','pre','3month','6months','pre','3month','6months','pre','3month','6months'
];

const result = repeatedMeasures(data, time, patients, { alpha: 0.05 });
/*
  {
    rejected: true,
    testValue: 12.53398058252424,
    pValue: 0.0018855906470255546,
    freedom: [ 2, 10 ]
  }
*/

Two-way ANOVA

import { twoWay } from 'ml-anova';

const data = [1, 2, 1, 3, 4, 5, 9, 10, 11];
const classesA = ['A', 'A', 'A', 'B', 'B', 'B', 'C', 'C', 'C'];
const classesB = ['X', 'X', 'X', 'X', 'X', 'X', 'Y', 'Y', 'Y'];

const result = twoWay(data, classesA, classesB, { alpha: 0.05 });
/*
{
  classA: {
    rejected: true,
    testValue: 304,
    pValue: 5.256992280576244e-11,
    freedom: [ 2, 12 ]
  },
  classB: {
    rejected: true,
    testValue: 691.4285714285716,
    pValue: 5.601171179813454e-12,
    freedom: [ 1, 12 ]
  },
  interaction: {
    rejected: true,
    testValue: 138.28571428571433,
    pValue: 5.170916200594281e-9,
    freedom: [ 2, 12 ]
  }
}
*/

License

MIT

anova's People

Contributors

stropitek avatar targos avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.