help prtab

Title

prtab -- Precision-recall curves

Syntax

prtab
refvar
classvar
[if] [in]
, [prtab_options]

prtab_options

Main
compare(varname) compares with another classifier

prec_at(real) affects the values of precision that are displayed

threshold uses the cutoff threshold for the horizontal axis

rank uses the item's rank for the horizontal axis

fscore plots the the F-score as a function of cutoff thresholds

interpolate provides an interpolated precision curve

Plot
nograph supresses graphical output

norefline does not display a reference line

twoway_options any options other than by() documented in [G-3] twoway_options

Description

prtab plots precision-recall curves. Precision-recall curves are an alternative to ROC curves for examining predictions of a binary outcome. See Cook and Ramadas (2018) for more details on precision-recall curves and this command.

Options

Main

compare(varname) compares with another classifier

prec_at(real) affects the values of precision that are displayed. The displayed values of precision will be around the specified value of recall. When rank is specified, this option is used to specify a rank.

thershold uses the cutoff threshold for the horizontal axis.

rank uses the item's rank for the horizontal axis. Note that if multiple observations have the same classifier score (i.e., there are ties), the precision is averaged of all possible rankings.

fscore plots the the F-score as a function of cutoff thresholds. The F-score is the harmonic mean of precision and recall.

interpolate provides an interpolated precision curve. Can be used with threshold, but not rank.

Plot

nograph surpresses graphical output.

norefline does not include a reference line in plot.

twoway_options are any of the options documented in [G-3] twoway_options, excluding by().

Example

Setup

. webuse ct2, clear

Create precision-recall curve

. prtab status mod1

Use plot options

. prtab status mod1, lwidth(medthick)

Compare two classifiers

. prtab status mod1, compare(mod2)

Saved results

Scalar

r(AUC) Area under the precision-recall curve (not provided if rank is used)

r(AUC2) Area under the precision-recall curve of the comparison classifier (only provided if compare is used)

r(N) Number of observations

r(unique_val) Number of unique classifier values (not provided if compare is used)

r(pos_cases) Number of positive cases

r(prct_pos) Percent of positive cases

Author

Jonathan Cook, jacook@uci.edu

References

Cook, J. and V. Ramadas. 2018. When to consult precision-recall curves. Working paper.