Skip to main content

Implementation of indexes used in statistical agreement

Project description

Statistical Agreement

How to assert agreement using statistical indices ?

Overview

This repo implements some indices used in statistical agreement such as total deviation index (TDI) and coverage probability (CP).

Statistical Agreement is an ensemble of processes to declare (or not) if two (or more) measurement methods lead to the same results.

Currently, only implementations for basic continuous or categorical models are planned.

Installation

pip install statisticalagreement

Usage

You can find examples in the example folder.

Here is an example of CCC usage with Gaussian simulated data:

from scipy. stats import multivariate_normal
import numpy as np
import statisticalagreement as sa

import seaborn as sns    
import matplotlib.pyplot as plt

mean=np.array([-np.sqrt(0.1)/2, np.sqrt(0.1)/2])
cov=np.array([[1.1**2, 0.95*1.1*0.9], [0.95*1.1*0.9, 0.9**2]])
xy = multivariate_normal.rvs(mean=mean, cov=cov, size=100)

x = xy[:, 0]
y = xy[:, 1]

ax = sns.histplot(x - y)
ax.set(xlabel="Difference of methods")
plt.show()

# Return approximate estimate of CCC 
# with a alpha risk of 5% 
# and an allowance of whithin sample deviation of 10%.
ccc = sa.ccc(x, y, method="approx", alpha=0.05, allowance=0.10)
print(f"Approximate estimate of CCC: {ccc.estimate:.4f}\n\
Lower confident interval of the estimate with confident level of 95%: {ccc.limit:.4f}\n")
Approximate estimate of CCC: 0.8943
Lower confident interval of the estimate with confident level of 95%: 0.8625

Since allowance > limit, then there is no allowance by criterion defined by the user.

The distribution of the difference of methods can be displayed for visual analysis. Distribution of difference of methods

Running the main.py with the argument -e will display the examples.

Current Implementations

For each index listed in the following table:

  • naive designes an implemetation using a parametric hypothesis (like a normal hypothesis), and thus only accurate if the hypothesis is true.
  • robust designes an implemetation not depending of any kind of hypothesis.
  • tested indicates if the implementation of the said index is tested with a monte-carlo test and results are correct in regards of the scientific literature.
  • bootstrap indicates if an alternative way to compute confident interval using a resample method is implemented.
  • unified model indicates if there is an implementation for models using continuous and categorical data (for instance with multiple raters and/or readings) - not planned currently
Index Naive Tested Robust Tested Bootstrap Unified model
MSD :heavy_check_mark: :heavy_check_mark:[^1] :x: :x: :x: :x:
TDI :heavy_check_mark: WIP :x: :x: :x: :x:
CP :heavy_check_mark: WIP :x: :x: :x: :x:
Accuracy :heavy_check_mark: :x: :x: :x: :x: :x:
Precision :heavy_check_mark: :x: :x: :x: :x: :x:
CCC :heavy_check_mark: :heavy_check_mark:[^1] WIP :x: :x: :x:
Kappa :heavy_check_mark: :heavy_check_mark:[^3] :x: :x: :x: :x:
Weighted Kappa :heavy_check_mark:[^2] :heavy_check_mark:[^3] :x: :x: :x: :x:

Test result

Implementation of the indices are tested with a monte-carlo simulation. The goal is to match results from the scientific literature. Currently tests of mc simulations can be display running main.py with the -s i argument where i is the index simulated.

Currently only msd and ccc tests are implemented. One can compare msd simulation results with \cite{LIN2000} and ccc one with \cite{LIN1989}.

References

Bibtex is available here.

[^1]: With normal data only [^2]: Absolute and Squared Weighted Kappa [^3]: Minimal testing based on examples found in \cite{LIN2013}

Troubleshooting

For VS Code users on Windows, using a venv to run the script can be prohibited due to ExecutionPolicy.

Get-ExecutionPolicy -List
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

statisticalagreement-0.5.0.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

statisticalagreement-0.5.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file statisticalagreement-0.5.0.tar.gz.

File metadata

  • Download URL: statisticalagreement-0.5.0.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for statisticalagreement-0.5.0.tar.gz
Algorithm Hash digest
SHA256 c6e46222556dbc8dd24ceed86eea165a305bcda983f7022e07486381a9c82949
MD5 2322761f7b4225e5439a7e2d4faf7338
BLAKE2b-256 50329868c27b1126b9ee694198e341f30bc4ec3786ea8930cc16c5c1760ae414

See more details on using hashes here.

File details

Details for the file statisticalagreement-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for statisticalagreement-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac004ff6894c82f25cf145353f3c6468ad973a242dfbb633b5cd38f8a1e8edd8
MD5 61045d404e73f0f3a4cad8edc2863912
BLAKE2b-256 15e9a8a2827a7accd7e85c4e18ddde1c0da7484d407bc166a88287a3f37e8bb4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page