Compute Signal Detection Theory Indices with R

[This article was first published on Dominique Makowski, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Signal Detection Theory Indices (dprime, beta…)

Signal detection theory (SDT) is used when psychologists want to measure the way we make decisions under conditions of uncertainty. SDT assumes that the decision maker is not a passive receiver of information, but an active decision-maker who makes difficult perceptual judgments under conditions of uncertainty. To apply signal detection theory to a data set where stimuli were either present or absent, and the observer categorized each trial as having the stimulus present or absent, the trials are sorted into one of four categories: Hit, Miss, Correct Rejection and False Alarm.

*Anderson (2015)*

Based on the proportions of these types of trials, we can compute indices of sensitivity and response bias:

  • d’ (d prime): The sensitivity. Reflects the distance between the two distributions: signal, and signal+noise and corresponds to the Z value of the hit-rate minus that of the false-alarm rate.
  • beta: The bias (criterion). The value for beta is the ratio of the normal density functions at the criterion of the Z values used in the computation of d’. This reflects an observer’s bias to say ‘yes’ or ‘no’ with the unbiased observer having a value around 1.0. As the bias to say ‘yes’ increases (liberal), resulting in a higher hit-rate and false-alarm-rate, beta approaches 0.0. As the bias to say ‘no’ increases (conservative), resulting in a lower hit-rate and false-alarm rate, beta increases over 1.0 on an open-ended scale.
  • A’ (aprime): Non-parametric estimate of discriminability. An A’ near 1.0 indicates good discriminability, while a value near 0.5 means chance performance.
  • B’‘D (b prime prime d): Non-parametric estimate of bias. A B’‘D equal to 0.0 indicates no bias, positive numbers represent conservative bias (i.e., a tendency to answer ‘no’), negative numbers represent liberal bias (i.e. a tendency to answer ‘yes’). The maximum absolute value is 1.0.
  • c: Another index of bias. the number of standard deviations from the midpoint between these two distributions, i.e., a measure on a continuum from “conservative” to “liberal”.

To compute them with psycho, simply run the following:

<span class="n">library</span><span class="p">(</span><span class="n">psycho</span><span class="p">)</span><span class="w">

</span><span class="c1"># Let's simulate three participants with different results at a perceptual detection task</span><span class="w">
</span><span class="n">df</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">data.frame</span><span class="p">(</span><span class="n">Participant</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="s2">"A"</span><span class="p">,</span><span class="w"> </span><span class="s2">"B"</span><span class="p">,</span><span class="w"> </span><span class="s2">"C"</span><span class="p">),</span><span class="w">
                 </span><span class="n">n_hit</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="m">1</span><span class="p">,</span><span class="w"> </span><span class="m">2</span><span class="p">,</span><span class="w"> </span><span class="m">5</span><span class="p">),</span><span class="w">
                 </span><span class="n">n_fa</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="m">1</span><span class="p">,</span><span class="w"> </span><span class="m">3</span><span class="p">,</span><span class="w"> </span><span class="m">5</span><span class="p">),</span><span class="w"> 
                 </span><span class="n">n_miss</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="m">6</span><span class="p">,</span><span class="w"> </span><span class="m">8</span><span class="p">,</span><span class="w"> </span><span class="m">1</span><span class="p">),</span><span class="w">
                 </span><span class="n">n_cr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="m">4</span><span class="p">,</span><span class="w"> </span><span class="m">8</span><span class="p">,</span><span class="w"> </span><span class="m">9</span><span class="p">))</span><span class="w">

</span><span class="n">indices</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">psycho</span><span class="o">::</span><span class="n">dprime</span><span class="p">(</span><span class="n">df</span><span class="o">$</span><span class="n">n_hit</span><span class="p">,</span><span class="w"> </span><span class="n">df</span><span class="o">$</span><span class="n">n_fa</span><span class="p">,</span><span class="w"> </span><span class="n">df</span><span class="o">$</span><span class="n">n_miss</span><span class="p">,</span><span class="w"> </span><span class="n">df</span><span class="o">$</span><span class="n">n_cr</span><span class="p">)</span><span class="w">
</span><span class="n">df</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">cbind</span><span class="p">(</span><span class="n">df</span><span class="p">,</span><span class="w"> </span><span class="n">indices</span><span class="p">)</span><span class="w">
</span>
Participant n_hit n_fa n_miss n_cr dprime beta aprime bppd c
A 1 1 6 4 -0.1925836 0.8518485 0.5000000 0.9459459 0.8326077
B 2 3 8 8 -0.1981923 0.8735807 0.4106061 0.8285714 0.6819377
C 5 5 1 9 0.9952151 0.8827453 0.5000000 -0.9230769 -0.1253182

To leave a comment for the author, please follow the link and comment on their blog: Dominique Makowski.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)