Skip to content

Credible intervals incorrect for values below threshold? #191

@LynnSchmittwilken

Description

@LynnSchmittwilken

Context

Great work on psignifit. While reproducing some of my results, however, I unfortunately stumbled across a potential issue with the credible intervals. Below a code example (three versions) which shows that credible intervals for performance values below the threshold seem to be incorrect.

Minimal example

import numpy as np
import psignifit as ps
from psignifit import psigniplot
import matplotlib.pyplot as plt


plotVersion = 3  # select which of the proposed versions to plot (1-3)

# Example from documentation:
data = np.array([[0.0010, 45.0000, 90.0000], [0.0015, 50.0000, 90.0000],
                 [0.0020, 44.0000, 90.0000], [0.0025, 44.0000, 90.0000],
                 [0.0030, 52.0000, 90.0000], [0.0035, 53.0000, 90.0000],
                 [0.0040, 62.0000, 90.0000], [0.0045, 64.0000, 90.0000],
                 [0.0050, 76.0000, 90.0000], [0.0060, 79.0000, 90.0000],
                 [0.0070, 88.0000, 90.0000], [0.0080, 90.0000, 90.0000],
                 [0.0100, 90.0000, 90.0000]])

options = {'sigmoid': 'norm',
           'experiment_type' : '2AFC'}

res = ps.psignifit(data, **options)

plt.figure()
psigniplot.plot_psychometric_function(res)


# Plot credible intervals across the whole curve
if plotVersion == 1: # produces an error
    y = np.linspace(0.5, 1, 50)  # get credible intervals between 50-100% performance
    CIlow = []; CIhigh = []
    for i in y:
        threshold, CI = res.threshold(i)  # use scaled sigmoid
        CIlow.append(CI[0][0]); CIhigh.append(CI[0][1])
    plt.plot(CIlow, y, label="lower bound"); plt.plot(CIhigh, y, label="upper bound")

elif plotVersion == 2:
    y = np.linspace(0.02, .5, 50) # get credible intervals according to error message of version 1
    CIlow = []; CIhigh = []
    for i in y:
        threshold, CI = res.threshold(i) # use scaled sigmoid
        CIlow.append(CI[0][0]); CIhigh.append(CI[0][1])
    plt.plot(CIlow, y+0.5, label="lower bound"); plt.plot(CIhigh, y+0.5, label="upper bound")

elif plotVersion == 3:
    y = np.linspace(0., 1, 50)  # get credible intervals over whole range for unscaled sigmoid
    CIlow = []; CIhigh = []
    for i in y:
        threshold, CI = res.threshold(i, unscaled=True) # use unscaled sigmoid instead
        CIlow.append(CI[0][0]); CIhigh.append(CI[0][1])
    
    y = np.linspace(0.5, 1, 50) # redefine to 50-100%
    plt.plot(CIlow, y, label="lower bound"); plt.plot(CIhigh, y, label="upper bound")

plt.legend()
plt.show()

Expected behavior

I would have expected that the psychometric function is always inbetween the credible intervals across the whole performance-range.

Observed behavior

The credible intervals for performance values below threshold (75% in the example) dont include the fitted function values.

Version 2 of code

image

Version 3 of code

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions