Descriptive Statistics in Single-Case Experimental Design#
The describe
function calculates comprehensive descriptive statistics for single-case experimental design (SCED) datasets. It provides detailed statistical information for each phase and case in the data.
Computing Descriptive Statistics with describe
#
The describe
function computes various descriptive statistics for each phase in a single-case dataset. It handles multiple cases and phases, providing a comprehensive statistical overview.
Required Arguments:#
data
: A Pandas DataFrame or list of DataFrames containing SCED data.
Optional Arguments:#
dvar
: The column name of the dependent variable (default determined automatically).pvar
: The column name of the phase variable (default determined automatically).mvar
: The column name representing measurement time (default determined automatically).return_dict
: If True, returns a dictionary with additional metadata (defaultFalse
).
The function calculates the following statistics for each phase:
n
: Number of observationsmis
: Number of missing valuesm
: Meanmd
: Mediansd
: Standard deviationmad
: Median absolute deviationmin
: Minimum valuemax
: Maximum valuetrend
: Linear trend coefficient
import scia as sc
📖 scia 1.101.0.dev6 - For Documentation, visit: https://ahsankhodami.github.io/scia/intro.html
Example 1: Basic Descriptive Statistics#
This example demonstrates how to compute basic descriptive statistics for a simple AB design dataset.
import pandas as pd
import numpy as np
df = sc.create_scd(
values=[5, 7, 8, 5, 7, 12, 16, 18, 15, 14, 19],
phase_starts={"A": 1, "B": 6}
)
# Compute descriptive statistics
sc.describe(df)
Case | Design | n.A | mis.A | m.A | md.A | sd.A | mad.A | min.A | max.A | trend.A | n.B | mis.B | m.B | md.B | sd.B | mad.B | min.B | max.B | trend.B | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | Case1 | A-B | 5.0 | 0.0 | 6.4 | 7.0 | 1.341641 | 1.4826 | 5.0 | 8.0 | 0.2 | 6.0 | 0.0 | 15.666667 | 15.5 | 2.581989 | 2.9652 | 12.0 | 19.0 | 0.742857 |
charlotte_test = sc.create_scd(
values={"A": [5, 7, 10, 5, 12], "B": [7, 10, 18, 15, 14, 19]},
name="Charlotte",
mt=list(range(11)) # Force mt to start from 0
)
theresa_test = sc.create_scd(
values={"A": [3, 4, 3, 5], "B": [7, 4, 7, 9, 8, 10, 12]},
name="Theresa",
mt=list(range(11)) # Force mt to start from 0
)
antonia_test = sc.create_scd(
values={"A": [9, 8, 8, 7, 5, 7], "B": [6, 14, 15, 12, 16]},
name="Antonia",
mt=list(range(11)) # Force mt to start from 0
)
mbd_test = [charlotte_test, theresa_test, antonia_test]
sc.describe(mbd_test)
Case | Design | n.A | mis.A | m.A | md.A | sd.A | mad.A | min.A | max.A | trend.A | n.B | mis.B | m.B | md.B | sd.B | mad.B | min.B | max.B | trend.B | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | Case1 | A-B | 5.0 | 0.0 | 7.800000 | 7.0 | 3.114482 | 2.9652 | 5.0 | 12.0 | 1.200000 | 6.0 | 0.0 | 13.833333 | 14.5 | 4.622409 | 5.9304 | 7.0 | 19.0 | 1.971429 |
1 | Case2 | A-B | 4.0 | 0.0 | 3.750000 | 3.5 | 0.957427 | 0.7413 | 3.0 | 5.0 | 0.500000 | 7.0 | 0.0 | 8.142857 | 8.0 | 2.544836 | 1.4826 | 4.0 | 12.0 | 1.000000 |
2 | Case3 | A-B | 6.0 | 0.0 | 7.333333 | 7.5 | 1.366260 | 0.7413 | 5.0 | 9.0 | -0.571429 | 5.0 | 0.0 | 12.600000 | 14.0 | 3.974921 | 2.9652 | 6.0 | 16.0 | 1.800000 |