help heckroc

Title

heckroc -- ROC curves for use with selected samples

Syntax

heckroc
refvar
classvar
[if] [in]
[weight]
, select([depvar_s =] varlist_s) [heckroc_options]

heckroc_options

Main
* select() specify selection equation: dependent and independent variables

collinear keep collinear variables

table display the raw data in a 2 x k contingency table

level(#) set confidence level; default is level(95)

noci do not display confidence intervals for inferred AUC curve

Plot
cbands display confidence bands for inferred ROC curve

noempirical do not include the empirical ROC curve in the plot

nograph supress graphical output

norefline do not display a reference line

irocopts(cline_options) affect rendition of inferred ROC curve

erocopts(cline_options) affect rendition of empirical ROC curve

rlopts(cline_options) affect rendition of reference line

cbands(cline_options) affect rendition of the confidence bands

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

SE/Robust
vce(vcetype) vcetype may be oim,
robust, cluster clustvar, opg, bootstrap, or
jackknife

Maximization
maximize_options control the maximization process

* select() is required. The full specification is

select([depvar_s =] varlist_s)

indepvars may contain factor variables; see fvvarlist.

depvar and indepvars may
contain time-series operators; see tsvarlist.

bootstrap, by, jackknife, nestreg,
rolling, statsby, stepwise, and svy
are allowed; see prefix.

Description

heckroc plots ROC curves that are robust to how the sample was selected. The ROC curves
are inferred from the data under assumptions that are similiar to those of type II
Tobit models. Details on the procedure used to create the inferred ROC curve are provided in Cook (2017)
and Cook and Rajbhandari (2017).

Options

Main

select() specify selection equation: dependent and independent variables;
whether to have constant term and offset variable. This option is required.

collinear keep collinear variables.

table display the raw data in a 2 x k contingency table

level(#); see
[R] estimation options.

noci do not display confidence intervals for inferred AUC.

Plot

cbands display confidence bands for inferred ROC curve.

noempirical do not include empirical ROC curve in plot.

nograph surpress graphical output.

norefline do not include a reference line in plot.

irocopts(cline_options) affect rendition of inferred ROC curve; see [G-3] cline_options

erocopts(cline_options) affect rendition of empirical ROC curve; see [G-3] cline_options

rlopts(cline_options) affect rendition of reference line; see [G-3] cline_options

cbands(cline_options) affect rendition of empirical ROC curve; see [G-3] cline_options

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

SE/Robust

vce(vcetype) specifies the type of standard error reported, which
includes types that are derived from asymptotic theory, that are robust to
some kinds of misspecification, that allow for intragroup correlation, and
that use bootstrap or jackknife methods; see
[R] vce_option.

vce(conventional), the default, uses the conventionally derived variance
estimators for first and second part models.

Maximization

maximize_options:
difficult, technique(algorithm_spec),
iterate(#), [no]log, trace,
gradient, showstep,
hessian,
showtolerance,
tolerance(#),
ltolerance(#),
nrtolerance(#),
nonrtolerance,
from(init_specs); see [R] maximize. These options are seldom
used.

Examples

Using Mroz data

Setup

. use http://fmwww.bc.edu/ec-p/data/wooldridge/mroz, clear

. gen high_wage = 0 if inlf

. replace high_wage = 1 if wage > 2.37 & inlf

Plot ROC curves using educ to predict high_wage

. heckroc high_wage educ, select(inlf= educ kidslt6 kidsge6 nwifeinc)

After logit

. quietly logit high_wage educ age exper if inlf

. predict predicted_xb, xb

. heckroc high_wage predicted_xb, select(inlf= predicted_xb educ kidslt6 kidsge6 nwifeinc)

Including plot options

. heckroc high_wage predicted_xb, select(inlf= predicted_xb educ kidslt6 kidsge6 nwifeinc) noempirical cbands irocopts(lcolor(black) lwidth(medthick)) rlopts(lcolor(gray))

Using provided data

Setup

. sysuse heckroc_example, clear

. replace outcome=. if !selected

Calling the command

. heckroc outcome rating_a, select(x rating_a rating_b) cbands

. heckroc outcome rating_b, select(x rating_a rating_b) cbands

Saved results

Scalar

e(AUC) AUC for the inferred ROC curve

e(EmpAUC) AUC for the empirical ROC curve

e(AUC_ub) Upper bound for AUC for the inferred ROC curve (not provided if option noci is used)

e(AUC_lb) Lower bound for AUC for the inferred ROC curve (not provided if option noci is used)

Authors

Jonathan Cook, jacook@uci.edu

Ashish Rajbhandari, arajbhandari@stata.com
StataCorp LLC

References

Cook, J. 2017. ROC curves and nonrandom data. Pattern Recognition Letters 85: 35-41. https://doi.org/10.1016/j.patrec.2016.11.015

Cook, J. and A. Rajbhandari 2017. heckroc: ROC curves for selected samples. Working paper. https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3043847