*! version 1.0.0 28November2020 Dirk Enzmann
help dichoct

Title

dichoct -- optimally dichotomizes a variable at a specified centile and generates a new variable containing the dichotomized values.

Syntax

dichoct varname [if] [in] , generate(newvar) [options]

options

generate(newvar) generate newvar containing dichotomized variable

centile(#) dichotomize variable at centile # (default: centile(50))

label(lbname) label values (0, 1) with the values of the centile

format(%fmt) display format for centile values (default: %6.0g)

by is allowed (see by)

Description

dichoct dichotomizes varname at the specified centile and
generates newvar containing the dichotomized values (0, 1). Dichotomizing a
variable at a specific centile will not always result in an optimal split (for
example, dichotomizing at values > or >= the centile value will yield different
results -- especially if the value of the centile is frequent and is not
exactly at the boundary of the interval including this value. dichoct chooses
to include or to not include the centile value in the upper interval of the
split (i.e. dichotomizes at values >= or > the centile value) so that an optimal
split is achieved. "Optimal" means that the resulting percentages of the values
of the dichotomized variable are closest to the desired percentages.

However, note that dichotomizing quantitative variables (although often
practiced) most often is a bad idea. You will loose information, reduce power, and
introduce measurement error. Using a dichotomized variable instead of the
original variable may introduce bias that is worse than the problem you intend
to solve by dichotomizing. Before you decide to dichotomize your variables you
should make sure that you are aware of the associated problems clearly described
in Cohen (1983), MacCallum et al. (2002), and DeCoster et al. (2009).

Options

Main

generate(newvar) specifies the name of the variable containing the
dichotomized values (0, 1) by splitting the variable varname at the
values of the centile specified with centile(#) or at its median if the
option centile(#) is not used. Values outside the range implied
by if or in are set to missing (.).

centile(#) specifies the centile at which to dichotomize the
variable varname. # can be of type int or real. If
centile(#) is not specified the variable will be split at its median (= centile(50)).

label(lblname) specifies the name of the value label of newvar (it
must not exist already). The labels contain the centile value at which the
variable varname has been dichotomized, indicating whether the centile
value is included or not in the lower value 0 (<= or <) or in the upper
value 1 (>= or >). Note that the option label(lblname) cannot be used
when dichotomizing a variable separately for each group as specified with the
command prefix by.

format(%fmt) sets the display format for centile values shown in the label
values, see format. The default is format(%6.0g).

Examples

Example 1 splits the variable "rep78" at its median (centile 50 = default)
and labels the values of the dichotomous variable with the values at which the
data have been split:

. sysuse auto, clear
(1978 Automobile Data)

. dichoct rep78, label(rep78_d) gen(rep78_d)
. tab1 rep78 rep78_d

-> tabulation of rep78

Repair |
Record 1978 | Freq. Percent Cum.

+

1 | 2 2.90 2.90
2 | 8 11.59 14.49
3 | 30 43.48 57.97
4 | 18 26.09 84.06
5 | 11 15.94 100.00

+

Total | 69 100.00

-> tabulation of rep78_d

rep78 split at |
centile 50 | Freq. Percent Cum.

+

rep78 <= 3 | 40 57.97 57.97
rep78 > 3 | 29 42.03 100.00

+

Total | 69 100.00

Example 2 demonstrates the use of the command
prefix by with dichoct to split the variable "price" at
centile 75 separately for each group of the variable "foreign". Note that the
option label(lblname) cannot be used in combination with by:

. sysuse auto, clear
(1978 Automobile Data)

. bys foreign: dichoct price, c(75) gen(price_d)
. by foreign: tab price_d

-> foreign = Domestic

price split |
at centile |
75 | Freq. Percent Cum.

+

0 | 39 75.00 75.00
1 | 13 25.00 100.00

+

Total | 52 100.00

-> foreign = Foreign

price split |
at centile |
75 | Freq. Percent Cum.

+

0 | 17 77.27 77.27
1 | 5 22.73 100.00

+

Total | 22 100.00

Returned results

Scalars:

r(k#) level # of group specified with by (# = 1 if no by-variable specified)

r(ct#) value of centile of level # of group specified with by

r(centile) centile to dichotomize variable varname

Macros:

r(ie#) inequality to dichotomize level # of group specified with by

r(by) variable(s) specifying groups with by

r(varname) name of dichotomized variable

References

Cohen, J. (1983). The cost of dichomization.
Applied Psychological Measurement, 7, 249-253.

DeCoster, J., Iselin, A.-M. R., & Gallucci, M. (2009).
A conceptual and empirical examination of justifications for dichotomization.
Psychological Methods, 14, 349-366.

MacCallum, R. C., Zhang, S., Preacher, K. J. & Rucker, D. D. (2002).
On the practice of dichotomization of quantitative variables.
Psychological Methods, 7, 19-40.

Author

Dirk Enzmann

Institute of Criminal Sciences, Hamburg

email: dirk.enzmann@uni-hamburg.de

Also see:

Online: centile