Standardized Mean Difference (SMD) — SCIA - Single Case Intervention Analysis with Python

Skip to main content
`Ctrl`+`K`

# Standardized Mean Difference (SMD)

The `smd` function computes standardized mean differences (effect sizes) for single-case experimental design (SCED) data. It supports both single-case and multiple-case datasets, and provides several effect size metrics including Cohen’s d, Hedges’ g, and Glass’ delta.

## Function Overview

The `smd` function calculates effect sizes between two phases (typically A and B) for SCED data. It can handle both a single DataFrame or a list of DataFrames (for multiple cases).

### Arguments

- `data`: DataFrame or list of DataFrames containing SCED data.

- `dvar`: Name of the dependent variable column (default: “values”).

- `pvar`: Name of the phase variable column (default: “phase”).

- `mvar`: Name of the measurement time variable column (default: “mt”).

- `phases`: Tuple or list of two phases to compare (default: (1, 2)).

### Returns

A DataFrame with effect size metrics for each case.

    import scia as sc

    📖 scia 1.101.0.dev6 - For Documentation, visit: https://ahsankhodami.github.io/scia/intro.html

## Example 1: Single-Case SMD Calculation

    # Create a single-case AB design
    df = sc.create_scd(
        values=[5, 7, 8, 5, 7, 12, 16, 18, 15, 14, 19],
        phase_starts={"A": 1, "B": 6}
    )

    # Compute standardized mean differences
    sc.smd(df)

| Case | mA | mB | sdA | sdB | sd cohen | sd hedges | Glass' delta | Hedges' g | Hedges' g correction | Hedges' g durlak correction | Cohen's d
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
0 | Default_Case | 6.4 | 15.666667 | 1.341641 | 2.581989 | 2.057507 | 2.122193 | 6.906966 | 4.366552 | 3.992276 | 3.61115 | 4.503833

## Example 2: Multiple-Case SMD Calculation

    # Create multiple cases
    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))
    )

    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))
    )

    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))
    )

    mbd_test = [charlotte_test, theresa_test, antonia_test]

    # Compute SMD for all cases
    sc.smd(mbd_test)

| Case | mA | mB | sdA | sdB | sd cohen | sd hedges | Glass' delta | Hedges' g | Hedges' g correction | Hedges' g durlak correction | Cohen's d
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
0 | Charlotte | 7.8 | 13.833333 | 3.114482 | 4.622409 | 3.941235 | 4.022621 | 1.937187 | 1.499851 | 1.371293 | 1.240381 | 1.530823
1 | Theresa | 3.75 | 8.142857 | 0.957427 | 2.544836 | 1.92261 | 2.15012 | 4.58819 | 2.043075 | 1.867955 | 1.689629 | 2.284841
2 | Antonia | 7.333333 | 12.6 | 1.36626 | 3.974921 | 2.972092 | 2.838883 | 3.854805 | 1.855189 | 1.696173 | 1.534246 | 1.77204

## Output

The output DataFrame contains the following columns for each case:

- `Case`: Case name

- `mA`, `mB`: Means for phases A and B

- `sdA`, `sdB`: Standard deviations for phases A and B

- `Glass' delta`: Glass’ delta effect size

- `sd hedges`: Pooled standard deviation for Hedges’ g

- `Hedges' g`: Hedges’ g effect size

- `Hedges' g correction`: Hedges’ g with small sample correction

- `Hedges' g durlak correction`: Hedges’ g with Durlak correction

- `sd cohen`: Pooled standard deviation for Cohen’s d

- `Cohen's d`: Cohen’s d effect size