3.1.2 • Published 2 years ago

@fullstax/kaplan-meier-estimator v3.1.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

kaplan-meier-estimator

A JavaScript implementation of the Kaplan-Meier-Estimator also known as the product limit estimator.

Installation

node

npm install --save kaplan-meier-estimator

Browser

<script src="https://unpkg.com/kaplan-meier-estimator@latest/lib/kaplan-meier-estimator.umd.js">

Usage

esm/typescript usage

See examples/node for an example implementation.

import { compute } from '@fullstax/kaplan-meier-estimator';

const timeToEvents = [1, 12, 22, 29, 31, …];
const events = [false, true, false, true, true, …];

const kmData = compute(timeToEvents, events);
console.table(kmData);

CommonJs is also supported:

const { compute } = require('@fullstax/kaplan-meier-estimator');

browser usage

See examples/browser for an example implementation. To server this example jsu start d webserver in the root of this repository.

<script src="https://unpkg.com/@fullstax/kaplan-meier-estimator/lib/kaplan-meier-estimator.umd.js">
const timeToEvents = [1, 12, 22, 29, 31, …];
const events = [false, true, false, true, true, …];

const kmData = KME.compute((timeToEvents, events);

console.table(kmData);

example output

┌─────────┬───────┬──────┬───────┐
│ (index) │  rate │ time │ event │
├─────────┼───────┼──────┼───────┤
│    0    │   1   │  1   │ false │
│    1    │ 0.929 │  12  │ true  │
│    2    │ 0.929 │  22  │ false │
│    3    │ 0.851 │  29  │ true  │
│    4    │ 0.774 │  31  │ true  │
│    …    │   …   │   …  │   …   │
└─────────┴───────┴──────┴───────┘

Example

Data

#Time to Eventevent>S(t)
11false1
212true0.93
322false0.93
429true0.85
531true0.77
636false0.77
738false0.77
850false0.77
960false0.77
1061true0.64
1170true0.52
1288false0.52
1399false0.52
14110false0.52
15140false0.52

Plot

Kaplan-Meier example plot, CC-0

License

Licensed 2022 by fullstax GmbH & Co. KG under a MIT License.

3.1.2

2 years ago

3.1.1

2 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago