Giter Club home page Giter Club logo

statcalc's Introduction

Statistical Calculators

coverage-badge

Statistics tools, including a kappa calculator and a Lin's concordance calculator.

Requirements

  • Python 3.x
  • Python dependencies (see requirements.txt for a complete listing)
  • Windows, MacOS, Linux or any other *nix OS

This project uses Python 3.x unittest module for tests. You may need to install the requirements first. Also, if you would like to view the test coverage, please install the coverage module using pip install coverage. For more information check the pip manual (pip -h).

To fetch the libraries that this code depends on, run this command within the statcalc folder

pip install -r requirements.txt

For running the tests.

python3 test.py

For measuring the coverage and producing an HTML report.

coverage run tests.py
coverage html

For updating the coverage badge, run the commands above, and then (after installing the coverage-badge module) run the coverage-badge command.

coverage-badge -o coverage.svg

Kappa calculator

Sample usage for kappa.py:

$ python kappa.py --npp 1.0 --npa 1.0 --nap 2.0 --naa 2.0 --kappatest 0.5
Results for 2x2 Interrater table
+-----------+-----------+--------+
| Rater A   | Rater B   | None   |
+===========+===========+========+
|           | present   | absent |
+-----------+-----------+--------+
| present   | 1         | 1      |
+-----------+-----------+--------+
| absent    | 2         | 2      |
+-----------+-----------+--------+
+-------------------------------------------------------------+
| kappahat = 0.0, (kappa+ = 0.0. kappa- = 0.0)                |
+-------------------------------------------------------------+
| s.e.(0) = 0.3849,  s.e.(kappahat) = 0.3849                  |
+-------------------------------------------------------------+
|                                                             |
+-------------------------------------------------------------+
| Hypothesis test p-values                                    |
+-------------------------------------------------------------+
| One-sided test, H0 is kappa =<0                             |
+-------------------------------------------------------------+
| p = Prob[>kappahat, given that kappa=0] = 0.5000            |
+-------------------------------------------------------------+
|                                                             |
+-------------------------------------------------------------+
| One-sided test, H0 is kappa =< 0.5                          |
+-------------------------------------------------------------+
| p = Prob[>kappahat, given that kappa= 0.5] = 0.9030         |
+-------------------------------------------------------------+
|                                                             |
+-------------------------------------------------------------+
| Two-sided test, H0 is kappa= 0.5                            |
+-------------------------------------------------------------+
| p = Prob[>|kappahat-kappa|, given that kappa= 0.5] = 0.1939 |
+-------------------------------------------------------------+

Sample usage for kappa_simple.py:

$ python kappa_simple.py --npp 1.0 --npa 1.0 --nap 2.0 --naa 2.0 --kappatest 0.5
Results for 2x2 Interrater table
+-----------+-----------+--------+
| Rater A   | Rater B   | None   |
+===========+===========+========+
|           | present   | absent |
+-----------+-----------+--------+
| present   | 1         | 1      |
+-----------+-----------+--------+
| absent    | 2         | 2      |
+-----------+-----------+--------+
+------------------------------------------------------------------+
| estimated kappa = 0.0                                            |
+------------------------------------------------------------------+
| s.e.(0) = 0.3849,  s.e.(estimated kappa) = 0.3849                |
+------------------------------------------------------------------+
| Hypothesis test p-values                                         |
+------------------------------------------------------------------+
| One-sided test, H0 is kappa <= 0.5                               |
+------------------------------------------------------------------+
| p = Prob[>estimated kappa, given that kappa= 0.90300.5] = 0.9030 |
+------------------------------------------------------------------+

Try python kappa.py -h for more or python kappa_simple.py -h.

Lin's Concordance calculator

Sample usage for links_concordance.py:

$ python lins_concordance.py "1~2~2~3~3~4"
+----------------------------------------------------------+
| Concordance Results                                      |
+==========================================================+
| Sample concordance correlation coefficient (pc) = 0.5714 |
+----------------------------------------------------------+
| Lower one-sided 95% CL for pc = -0.193                   |
+----------------------------------------------------------+
| Lower two-sided 95% CL for pc = -0.343                   |
+----------------------------------------------------------+
| Upper one-sided 95% CL for pc = 0.9043                   |
+----------------------------------------------------------+
| Upper two-sided 95% CL for pc = 0.9298                   |
+----------------------------------------------------------+

Try python lins_concordance.py -h for more.

statcalc's People

Contributors

craigstanton avatar darbyrt avatar kinow avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  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.