measure of response bias, based on the ratio of the likelihood the decision variable obtains a certain value on signal trials, to the likelihood that it obtains the value on noise trials.
=for html *beta* = exp( ( (phi^{–1}(*far*)^{2} – phi^{–1}(*hr*)^{2}) ) / 2 )

Values less than 1 indicate a bias toward the I response, values greater than 1 indicate a bias toward the I response, and the value of 1 indicates no bias toward I or I.
=item log_likelihood_bias
Returns the natural logarithm of the likelihood bias, I.
Ranges from -1 to +1, with values less than 0 indicating a bias toward the I response, values greater than 0 indicating a bias toward the I response, and a value of 0 indicating no response bias.
=item c (or) decision_bias
Implements the I parametric measure of response bias. Ranges from -1 to +1, with deviations from zero, measured in standard deviation units, indicating the position of the decision criterion with respect to the neutral point where the signal and noise distributions cross over, there is no response bias, and I = 0.
Values less than 0 indicate a bias toward the I response; values greater than 0 indicate a bias toward the I response; and a value of 0 indicates no response bias.
=item griers_bias
Implements Griers I** nonparametric measure of response bias.
Ranges from -1 to +1, with values less than 0 indicating a bias toward the I response, values greater than 0 indicating a bias toward the I response, and a value of 0 indicating no response bias.
=back
=cut
# --------------------
sub bias {
# --------------------
my $self = shift;
local $_ = shift;
my %args = ref $_[0] ? %{(shift)} : (); # optimistic
CASE:{
/^b|li/i && do { return $self->_likelihood_bias(%args); };
/^lo/i && do { return $self->_log_likelihood_bias(%args); };
/^c|d/i && do { return $self->_decision_bias(%args); };
/^g/i && do { return $self->_griers_bias(%args)};
} #end CASE
}
sub _likelihood_bias { # beta
my $self = shift;print "args = ", join(', ', @_), "\n";
my ($h, $f) = $self->init(@_);#print "init: hr = $h far = $f\n";
return _precisioned($self->{'precision_s'}, exp( ( ( (ndtri($f)**2) - (ndtri($h)**2) ) / 2 ) ) );
}
sub _log_likelihood_bias { # ln(beta)
my $self = shift;
my ($h, $f) = $self->init(@_);
return _precisioned($self->{'precision_s'}, ( ( (ndtri($f)**2) - (ndtri($h)**2) ) / 2 ));
}
sub _decision_bias { # c
my $self = shift;
my ($h, $f) = $self->init(@_);
return _precisioned($self->{'precision_s'}, -1 *( ( ndtri($h) + ndtri($f) ) / 2 ) );
}
sub _griers_bias { # B''
my $self = shift;
my ($h, $f) = $self->init(@_);
my ($a, $b, $c) = ();
if ($h >= $f) {
$a = ( $h * (1 - $h) );
$b = ( $f * (1 - $f) );
$c = ( $a - $b ) / ( $a + $b );
}
else {
$a = ( $f * (1 - $f) );
$b = ( $h * (1 - $h) );
$c = ( $a - $b ) / ( $a + $b );
}
return _precisioned($self->{'precision_s'}, $c);
}
=head2 criterion
$sdt->criterion() # assume d' and c can be calculated from already inited param values
$sdt->criterion(d => float, c => float)
I: C, C
Returns the value of the criterion for given values of sensitivity I and bias I, viz.: I = I / 2 + I.
=cut
# --------------------
sub criterion {
# --------------------
my $dc = _get_dc(@_);
return _precisioned($_[0]->{'precision_s'}, ($dc->{'d'} / 2) + $dc->{'c'} );
}
*dc2k = \&criterion; # Alias
*crit = \&criterion;
=head2 dc2hr
$sdt->dc2hr() # assume d' and c can be calculated from already inited param values
$sdt->dc2hr(d => float, c => float)
Returns the hit-rate estimated from given values of sensitivity I and bias I, viz.: I**

= phi(I / 2 - I).
=cut
# --------------------
sub dc2hr {
# --------------------
my $dc = _get_dc(@_);
return _precisioned($_[0]->{'precision_s'}, ndtr(($dc->{'d'} / 2) - $dc->{'c'}) );
}
=head2 dc2far
$sdt->dc2far() # assume d' and c can be calculated from already inited param values
$sdt->dc2far(d => float, c => float)
Returns the false-alarm-rate estimated from given values of sensitivity I and bias I, viz.: I = phi(-I / 2 - I).
=cut
# --------------------
sub dc2far {
# --------------------
my $dc = _get_dc(@_);
return _precisioned($_[0]->{'precision_s'}, ndtr(-1*($dc->{'d'} / 2) - $dc->{'c'}) );
}
=head2 dc2logbeta
$sdt->dc2logbeta() # assume d' and c can be calculated from already inited param values
$sdt->dc2logbeta(d => float, c => float)
Returns the log-likelihood (beta) bias estimated from given values of sensitivity I and bias I, viz.: I** = I . I.
=cut
# --------------------
sub dc2logbeta {
# --------------------
my $dc = _get_dc(@_);
return _precisioned($_[0]->{'precision_s'}, $dc->{'d'} * $dc->{'c'} );
}
sub _get_dc {
my ($self, %params) = @_;
my %dc = ();
foreach (qw/d c/) {
$dc{$_} = $params{$_} if defined $params{$_};
}
$dc{'d'} = $self->sensitivity('d') if !defined $dc{'d'};
$dc{'c'} = $self->bias('c') if !defined $dc{'c'};
return \%dc;
}
sub _init_rate {# Initialise hit and false-alarm rates:
my ($count, $trials, $correction) = @_;
my $rate;
$correction = 1 if !defined $correction; # default correction
# Need (i) no. of hits and signal trials, or (ii) no. of false alarms and noise trials:
croak __PACKAGE__, " Number of hits/false-alarms and signal/noise trials needed to calculate rate" if ! defined $count || ! defined $trials;
if ($correction > 1) { # loglinear correction, regardless of values:
$rate = _loglinear_correct($count, $trials);
}
else { # get rate first, applying corrections if needed (unless explicitly verboten):
$rate = $count / $trials;
unless ($correction == 0) {
$rate = _n_correct($rate, $trials);
}
}
return $rate;
}
sub _loglinear_correct {
return ($_[0] + .5) / ($_[1] + 1); # either hits & signal_trials; or false_alarms and noise_trials
}
sub _n_correct {
my ($rate, $trials) = @_;
my $retval;
if (! $rate) {
$retval = .5 / $trials;
}
elsif ($rate == 1) {
$retval = ($trials - .5) / $trials;
}
else {
$retval = $rate;
}
return $retval;
}
sub _precisioned {
return $_[0] ? sprintf('%.' . $_[0] . 'f', $_[1]) : $_[1];
}
sub _valid_p {
my $p = shift;
return ($p !~ /^0?\.\d+$/) || ($p < 0 || $p > 1) ? 0 : 1;
}
1;
__END__
=head1 REFERENCES
Alexander, J. R. M. (2006). An approximation to I for I-alternative forced choice. From L.
Lee, M. D. (2008). BayesSDT: Software for Bayesian inference with signal detection theory. I, I<40>, 450-456.
Smith, J. E. K. (1982). Simple algorithms for I-alternative forced-choice calculations. I, I<31>, 95-96.
Stanislaw, H., & Todorov, N. (1999). Calculation of signal detection theory measures. I, I<31>, 137-149.
Swets, J. A. (1964). I. New York, NY, US: Wiley.
=head1 SEE ALSO
L : The present module imports/depends upon the L (I) and L (I) functions from this package.
L : Receiver-operator characteristic curves.
=head1 LIMITATIONS/TODO
Expects descriptive counts, not raw observations, confidence ratings; this limits the measures that can be implemented: methods C and C are reserved to implement handling of data lists.
Perl's C modules do not seem to effect the required validation of parameters needed for each measure; the present work-around is obsessive-compulsive, while not exhaustive of all wayward possibilities, and requires optimisation but extension. It is presently quite possible to suffer an inelegant death should anything too unsual, or impoverished of details, be attempted in the life of the module.
=head1 REVISION HISTORY
See Changes file in installation dist.
=head1 AUTHOR/LICENSE
=over 4
=item Copyright (c) 2006-2013 Roderick Garton
rgarton AT cpan DOT org
This program is free software. It may be used, redistributed and/or modified under the same terms as Perl-5.6.1 (or later) (see L).
=item Disclaimer
To the maximum extent permitted by applicable law, the author of this module disclaims all warranties, either express or implied, including but not limited to implied warranties of merchantability and fitness for a particular purpose, with regard to the software and the accompanying documentation.
=back
=head1 END
This ends documentation for a Perl implementation of signal detection theory measures of sensitivity and bias.
=cut
**