singlecase


Namesinglecase JSON
Version 0.2.2 PyPI version JSON
download
home_page
SummaryA tool for single-case design data management, statistical analysis and visualization.
upload_time2023-11-18 13:24:40
maintainer
docs_urlNone
author
requires_python>=3.8
licenseBSD 3-Clause License Copyright (c) 2023, Casper Wilstrup Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords single case permutation test pnd nap effect size non-overlapping statistical analysis research
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Single Case Research Package

*By Casper Wilstrup*

The Single Case Research package is a Python library designed to assist in conducting single-case research studies. The package provides tools to analyze single-case data sets. It is designed for simplicity and ease of use, with a range of methods to calculate various statistical measures for single-case data sets. The package is useful for analysts and researchers dealing with single-case designs, providing a framework to load, manage, and manipulate such data, along with robust statistical functions to interpret the data.

More functionality will be added as the package is further developed

## Installation

You can install the package using pip:

```shell
pip install singlecase
```


## Usage

To use `singlecase`, first import the package into your Python environment:

```python
from singlecase.data import Data
```

Then, create a `Data` object with either a pandas DataFrame or a dictionary:

```python
data = Data({
    'phase': ['A1', 'A1', 'A1', 'B', 'B', 'B', 'A2', 'A2', 'A2'],
    'dvar1': [1.0, 2.5, 3.2, 4.2, 5.5, 6.2, 2.0, 2.4, 3.1],
    'dvar2': [2.5, 3.2, 4.6, 5.6, 6.2, 7.8, 3.3, 4.1, 4.8],
})
```

Now you're ready to perform single-case data analysis.

## Core Features

### Data Class

The `Data` class provides an object-oriented interface to represent your single-case data. It assumes any variable with datatype of float as a dependent variable. The dependent and phase variables can be accessed and modified using properties. For example:

```python
data.pvar = 'column_name'  # Set the phase variable, if it is not named 'phase'
```

### Nonoverlap Pairs (NAP)

The `nap` function computes the Nonoverlap Pairs between two phases in a single-case data frame. It returns a pandas Series containing the NAP values for each dependent variable in the data set.

```python
from singlecase.effectsize import nap
nap_values = nap(data, phases["A1", "B"])
```

### Percent Non-overlapping Data (PND)

The `pnd` function computes the Percent Non-overlapping Data between two phases in a single-case data frame. It returns a pandas Series containing the PND values for each dependent variable in the data set.

```python
from singlecase.effectsize import pnd
pnd_values = pnd(data, phases=["A1", "B"])
```

### Permutation Test

The `permutation_test` function performs a permutation test between two phases in a single-case data frame. It returns a pandas Series containing the p-values for each dependent variable in the data set. The p-value is the probability that the two phases have the same mean.

```python
from singlecase.permtest import permutation_test
p_values = permutation_test(data, phases=["A1","A2"])
```


## Complete example

This complete example creates a new `singlecase.Data` from a Python dictionary. The dataset has two dependent variables `dvar1` and `dvar2`. The phase variable is called `phase` and consists of the two phases "A" and "B". Based on this data, the PND and NAP values are calculated and printed. The probability that the two phases have the same mean is then calculated using permutation tests and printed. Since the data contains only two phases, it is not necessary to specify which phases to compare in `pnd`, `nap` and `permutation_test` function calls.

```python
import pandas as pd
from singlecase.data import Data
from singlecase.effectsize import pnd, nap
from singlecase.permtest import permutation_test

# Create a sample data
data_dict = {
    'phase': ['A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B', 'B'],
    'dvar1': [1.0, 2.5, 3.2, 4.6, 2.8, 5.6, 3.7, 4.2, 5.5, 6.2, 7.3, 8.5],
    'dvar2': [2.5, 3.2, 4.6, 5.1, 4.8, 5.2, 6.7, 5.6, 6.2, 7.8, 8.4, 7.2],
}

# Instantiate Data object
data = Data(data_dict)

# Calculate PND
pnd_values = pnd(data)
print(f"PND values:\n{pnd_values}\n")

# Calculate NAP
nap_values = nap(data)
print(f"NAP values:\n{nap_values}\n")

# Calculate the p-value the mean of the two phases being the same
perm_p = permutation_test(data)
print(f"Probability that A and B phases have same mean:\n{perm_p}\n")
```


## License

This project is licensed under the BSD 3-clause license - see the LICENSE file for details.

## About the package

The Single Case Research package is supported by [Abzu](https://www.abzu.ai) as part of an ongoing mission to improve scientific research powered by artificial intelligence.

The primary author of the package is [Casper Wilstrup](https://twitter.com/cwilstrup). New contributors are welcome.


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "singlecase",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "single case,permutation test,pnd,nap,effect size,non-overlapping,statistical analysis,research",
    "author": "",
    "author_email": "Casper Wilstrup <casper.wilstrup@abzu.ai>",
    "download_url": "https://files.pythonhosted.org/packages/83/f8/691c484f1cbc3016ad02efc9aee20cc6d414c83006b263ebdaf923c29616/singlecase-0.2.2.tar.gz",
    "platform": null,
    "description": "# Single Case Research Package\n\n*By Casper Wilstrup*\n\nThe Single Case Research package is a Python library designed to assist in conducting single-case research studies. The package provides tools to analyze single-case data sets. It is designed for simplicity and ease of use, with a range of methods to calculate various statistical measures for single-case data sets. The package is useful for analysts and researchers dealing with single-case designs, providing a framework to load, manage, and manipulate such data, along with robust statistical functions to interpret the data.\n\nMore functionality will be added as the package is further developed\n\n## Installation\n\nYou can install the package using pip:\n\n```shell\npip install singlecase\n```\n\n\n## Usage\n\nTo use `singlecase`, first import the package into your Python environment:\n\n```python\nfrom singlecase.data import Data\n```\n\nThen, create a `Data` object with either a pandas DataFrame or a dictionary:\n\n```python\ndata = Data({\n    'phase': ['A1', 'A1', 'A1', 'B', 'B', 'B', 'A2', 'A2', 'A2'],\n    'dvar1': [1.0, 2.5, 3.2, 4.2, 5.5, 6.2, 2.0, 2.4, 3.1],\n    'dvar2': [2.5, 3.2, 4.6, 5.6, 6.2, 7.8, 3.3, 4.1, 4.8],\n})\n```\n\nNow you're ready to perform single-case data analysis.\n\n## Core Features\n\n### Data Class\n\nThe `Data` class provides an object-oriented interface to represent your single-case data. It assumes any variable with datatype of float as a dependent variable. The dependent and phase variables can be accessed and modified using properties. For example:\n\n```python\ndata.pvar = 'column_name'  # Set the phase variable, if it is not named 'phase'\n```\n\n### Nonoverlap Pairs (NAP)\n\nThe `nap` function computes the Nonoverlap Pairs between two phases in a single-case data frame. It returns a pandas Series containing the NAP values for each dependent variable in the data set.\n\n```python\nfrom singlecase.effectsize import nap\nnap_values = nap(data, phases[\"A1\", \"B\"])\n```\n\n### Percent Non-overlapping Data (PND)\n\nThe `pnd` function computes the Percent Non-overlapping Data between two phases in a single-case data frame. It returns a pandas Series containing the PND values for each dependent variable in the data set.\n\n```python\nfrom singlecase.effectsize import pnd\npnd_values = pnd(data, phases=[\"A1\", \"B\"])\n```\n\n### Permutation Test\n\nThe `permutation_test` function performs a permutation test between two phases in a single-case data frame. It returns a pandas Series containing the p-values for each dependent variable in the data set. The p-value is the probability that the two phases have the same mean.\n\n```python\nfrom singlecase.permtest import permutation_test\np_values = permutation_test(data, phases=[\"A1\",\"A2\"])\n```\n\n\n## Complete example\n\nThis complete example creates a new `singlecase.Data` from a Python dictionary. The dataset has two dependent variables `dvar1` and `dvar2`. The phase variable is called `phase` and consists of the two phases \"A\" and \"B\". Based on this data, the PND and NAP values are calculated and printed. The probability that the two phases have the same mean is then calculated using permutation tests and printed. Since the data contains only two phases, it is not necessary to specify which phases to compare in `pnd`, `nap` and `permutation_test` function calls.\n\n```python\nimport pandas as pd\nfrom singlecase.data import Data\nfrom singlecase.effectsize import pnd, nap\nfrom singlecase.permtest import permutation_test\n\n# Create a sample data\ndata_dict = {\n    'phase': ['A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B', 'B'],\n    'dvar1': [1.0, 2.5, 3.2, 4.6, 2.8, 5.6, 3.7, 4.2, 5.5, 6.2, 7.3, 8.5],\n    'dvar2': [2.5, 3.2, 4.6, 5.1, 4.8, 5.2, 6.7, 5.6, 6.2, 7.8, 8.4, 7.2],\n}\n\n# Instantiate Data object\ndata = Data(data_dict)\n\n# Calculate PND\npnd_values = pnd(data)\nprint(f\"PND values:\\n{pnd_values}\\n\")\n\n# Calculate NAP\nnap_values = nap(data)\nprint(f\"NAP values:\\n{nap_values}\\n\")\n\n# Calculate the p-value the mean of the two phases being the same\nperm_p = permutation_test(data)\nprint(f\"Probability that A and B phases have same mean:\\n{perm_p}\\n\")\n```\n\n\n## License\n\nThis project is licensed under the BSD 3-clause license - see the LICENSE file for details.\n\n## About the package\n\nThe Single Case Research package is supported by [Abzu](https://www.abzu.ai) as part of an ongoing mission to improve scientific research powered by artificial intelligence.\n\nThe primary author of the package is [Casper Wilstrup](https://twitter.com/cwilstrup). New contributors are welcome.\n\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License  Copyright (c) 2023, Casper Wilstrup  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
    "summary": "A tool for single-case design data management, statistical analysis and visualization.",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://github.com/wilstrup/singlecase"
    },
    "split_keywords": [
        "single case",
        "permutation test",
        "pnd",
        "nap",
        "effect size",
        "non-overlapping",
        "statistical analysis",
        "research"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "04e588a973cb86e9054e151022028e9439b52306536183285592853607db09a8",
                "md5": "c9971f7c492c565cb74c6788ffbfe88d",
                "sha256": "4021789d786f392dd5f49d0de7eac6a339c588a31f81073a5bc197426cfb049a"
            },
            "downloads": -1,
            "filename": "singlecase-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c9971f7c492c565cb74c6788ffbfe88d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 10248,
            "upload_time": "2023-11-18T13:24:38",
            "upload_time_iso_8601": "2023-11-18T13:24:38.464466Z",
            "url": "https://files.pythonhosted.org/packages/04/e5/88a973cb86e9054e151022028e9439b52306536183285592853607db09a8/singlecase-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "83f8691c484f1cbc3016ad02efc9aee20cc6d414c83006b263ebdaf923c29616",
                "md5": "40fe2508ce10c38cc34526b2db21dce4",
                "sha256": "5102e687d7f25f8ac300612a1d6311b3e54e3d7c3d126a06ec3fb8972cfed8fa"
            },
            "downloads": -1,
            "filename": "singlecase-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "40fe2508ce10c38cc34526b2db21dce4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 10801,
            "upload_time": "2023-11-18T13:24:40",
            "upload_time_iso_8601": "2023-11-18T13:24:40.446901Z",
            "url": "https://files.pythonhosted.org/packages/83/f8/691c484f1cbc3016ad02efc9aee20cc6d414c83006b263ebdaf923c29616/singlecase-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-18 13:24:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "wilstrup",
    "github_project": "singlecase",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "singlecase"
}
        
Elapsed time: 0.15458s