Nonoverlap of All Pairs (NAP)#

The nap function calculates the Nonoverlap of All Pairs (NAP) for single-case data. NAP is a non-parametric effect size measure that quantifies the proportion of data pairs showing improvement between two phases.

Function Overview#

The nap function computes NAP values along with several related statistics including Mann-Whitney U test results and effect sizes.

Arguments#

  • data: DataFrame or list of DataFrames containing single-case data

  • dvar: Name of dependent variable column (default: “values”)

  • pvar: Name of phase variable column (default: “phase”)

  • decreasing: If True, lower values in Phase B indicate improvement (default: False)

  • phases: Tuple of phases to compare (default: (“A”, “B”))

Returns#

A DataFrame with:

  • NAP and rescaled NAP values

  • Number of pairs and non-overlapping pairs

  • Mann-Whitney U test results (W statistic and p-value)

  • Effect sizes (d and R²)

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

Example 1: Single-Case NAP 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 NAP
sc.nap(df)
Case NAP NAP Rescaled Pairs Non-overlaps Positives Ties W p d
0 NAs 100.0 100.0 30.0 30.0 30.0 0.0 0.0 0.003914 3.464 0.749989

Example 2: Multiple-Case NAP Calculation#

# Create multiple cases
case1 = sc.create_scd(values={"A": [5, 7, 8, 5, 7], "B": [12, 16, 18, 15, 14, 19]})
case2 = sc.create_scd(values={"A": [3, 4, 5, 3], "B": [6, 7, 8, 9, 10, 11, 12]})
case3 = sc.create_scd(values={"A": [6, 8, 7, 8, 7, 8], "B": [10, 12, 13, 14, 15]})

# Compute NAP for all cases
sc.nap([case1, case2, case3])
Case NAP NAP Rescaled Pairs Non-overlaps Positives Ties W p d
0 1 100.0 100.0 30.0 30.0 30.0 0.0 0.0 0.003914 3.464 0.749989
1 2 100.0 100.0 28.0 28.0 28.0 0.0 0.0 0.005278 3.464 0.749989
2 3 100.0 100.0 30.0 30.0 30.0 0.0 0.0 0.003704 3.464 0.749989

Notes#

  • NAP values range from 50% (no effect) to 100% (complete separation)

  • The rescaled version ranges from 0% to 100% for easier interpretation

  • For decreasing outcomes (where lower values indicate improvement), set decreasing=True

  • The function also provides Mann-Whitney U test results and effect sizes