StatisticalAgreement


NameStatisticalAgreement JSON
Version 0.4.0 PyPI version JSON
download
home_pageNone
SummaryImplementation of indexes used in statistical agreement
upload_time2024-09-03 11:44:48
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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 process 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.

## Usage

This project is not a proper python package yet. It will be distributed in the future via Pypi. Thus, to use it, you need to clone the current repo and include in your project.

You can find examples in the example folder.

Here is an example of CCC usage with Gaussian simulated data:
```python
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](plots/histplot_difference_methods_simalution_example.png?raw=true "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](bibliography.bib).

[^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. 
```powershell
Get-ExecutionPolicy -List
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
```
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "StatisticalAgreement",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Cases R\u00e9my <remy.cases@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/de/84/6ac3d13d72e5a8a24231cb028ad376de82959c55340bd5e4b5c64a42572b/statisticalagreement-0.4.0.tar.gz",
    "platform": null,
    "description": "# Statistical Agreement\nHow to assert agreement using statistical indices ?\n\n## Overview\n\nThis repo implements some indices used in statistical agreement such as total deviation index (TDI) and coverage probability (CP). \n\nStatistical Agreement is an ensemble of process to declare (or not) if two (or more) measurement methods lead to the same results.\n\nCurrently, only implementations for basic continuous or categorical models are planned.\n\n## Usage\n\nThis project is not a proper python package yet. It will be distributed in the future via Pypi. Thus, to use it, you need to clone the current repo and include in your project.\n\nYou can find examples in the example folder.\n\nHere is an example of CCC usage with Gaussian simulated data:\n```python\nfrom scipy. stats import multivariate_normal\nimport numpy as np\nimport StatisticalAgreement as sa\n\nimport seaborn as sns    \nimport matplotlib.pyplot as plt\n\nmean=np.array([-np.sqrt(0.1)/2, np.sqrt(0.1)/2])\ncov=np.array([[1.1**2, 0.95*1.1*0.9], [0.95*1.1*0.9, 0.9**2]])\nxy = multivariate_normal.rvs(mean=mean, cov=cov, size=100)\n\nx = xy[:, 0]\ny = xy[:, 1]\n\nax = sns.histplot(x - y)\nax.set(xlabel='Difference of methods')\nplt.show()\n\n# Return approximate estimate of CCC \n# with a alpha risk of 5% \n# and an allowance of whithin sample deviation of 10%.\nccc = sa.ccc(x, y, method='approx', alpha=0.05, allowance=0.10)\nprint(f\"Approximate estimate of CCC: {ccc.estimate:.4f}\\n\\\nLower confident interval of the estimate with confident level of 95%: {ccc.limit:.4f}\\n\")\n```\n```\nApproximate estimate of CCC: 0.8943\nLower confident interval of the estimate with confident level of 95%: 0.8625\n```\n\nSince `allowance > limit`, then there is no allowance by criterion defined by the user.\n\nThe distribution of the difference of methods can be displayed for visual analysis.\n![Distribution of difference of methods](plots/histplot_difference_methods_simalution_example.png?raw=true \"Distribution of difference of methods\")\n\nRunning the `main.py` with the argument `-e` will display the examples.\n\n## Current Implementations\n\nFor each index listed in the following table:\n- **naive** designes an implemetation using a parametric hypothesis (like a **normal** hypothesis), and thus only accurate if the hypothesis is true.\n- **robust** designes an implemetation not depending of any kind of hypothesis.\n- **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. \n- **bootstrap** indicates if an alternative way to compute confident interval using a resample method is implemented.\n- **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*\n\n|Index | Naive | Tested | Robust |  Tested | Bootstrap | Unified model | \n|--|:--:|:--:|:--:|:--:|:--:|:--:|\n| MSD |:heavy_check_mark:|:heavy_check_mark:[^1]|:x:|:x:|:x:|:x:\n| TDI |:heavy_check_mark:|WIP|:x:|:x:|:x:|:x:\n| CP |:heavy_check_mark:|WIP|:x:|:x:|:x:|:x:\n| Accuracy |:heavy_check_mark:|:x:|:x:|:x:|:x:|:x:\n| Precision |:heavy_check_mark:|:x:|:x:|:x:|:x:|:x:\n| CCC |:heavy_check_mark:|:heavy_check_mark:[^1]|WIP|:x:|:x:|:x:\n| Kappa |:heavy_check_mark:|:heavy_check_mark:[^3]|:x:|:x:|:x:|:x:\n| Weighted Kappa |:heavy_check_mark:[^2]|:heavy_check_mark:[^3]|:x:|:x:|:x:|:x:\n\n## Test result\n\nImplementation 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.\n\nCurrently only `msd` and `ccc` tests are implemented. One can compare `msd` simulation results with \\cite{LIN2000} and `ccc` one with \\cite{LIN1989}.\n\n## References\n\nBibtex is available [here](bibliography.bib).\n\n[^1]: With normal data only\n[^2]: Absolute and Squared Weighted Kappa\n[^3]: Minimal testing based on examples found in \\cite{LIN2013}\n\n## Troubleshooting\n\nFor VS Code users on Windows, using a venv to run the script can be prohibited due to ExecutionPolicy. \n```powershell\nGet-ExecutionPolicy -List\nSet-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine\n```",
    "bugtrack_url": null,
    "license": null,
    "summary": "Implementation of indexes used in statistical agreement",
    "version": "0.4.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/remyCases/StatisticalAgreement/issues",
        "Homepage": "https://github.com/remyCases/StatisticalAgreement"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e6151de5fe4896997a031f24ff56c433f41d2b8b7d31c3ca950408d077de33c3",
                "md5": "674e35b0aa51bf4795ef6edf35cd674d",
                "sha256": "4f589f7e184b95bea83481c459ec4f7643909cd1a448ced8027adfb0439a9de9"
            },
            "downloads": -1,
            "filename": "statisticalagreement-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "674e35b0aa51bf4795ef6edf35cd674d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 14654,
            "upload_time": "2024-09-03T11:44:46",
            "upload_time_iso_8601": "2024-09-03T11:44:46.627580Z",
            "url": "https://files.pythonhosted.org/packages/e6/15/1de5fe4896997a031f24ff56c433f41d2b8b7d31c3ca950408d077de33c3/statisticalagreement-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "de846ac3d13d72e5a8a24231cb028ad376de82959c55340bd5e4b5c64a42572b",
                "md5": "55e98316dc0decd9a3cf95258dd307b2",
                "sha256": "e301bd29436d63f89bad14da1bef1bd35ae37f0f6b54599c5b5f9bee3facf402"
            },
            "downloads": -1,
            "filename": "statisticalagreement-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "55e98316dc0decd9a3cf95258dd307b2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 25368,
            "upload_time": "2024-09-03T11:44:48",
            "upload_time_iso_8601": "2024-09-03T11:44:48.588333Z",
            "url": "https://files.pythonhosted.org/packages/de/84/6ac3d13d72e5a8a24231cb028ad376de82959c55340bd5e4b5c64a42572b/statisticalagreement-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-03 11:44:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "remyCases",
    "github_project": "StatisticalAgreement",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "statisticalagreement"
}
        
Elapsed time: 0.32413s