-------------------------------------------------------------------------------
help for firstdigit
-------------------------------------------------------------------------------

First digits of numeric variables

firstdigit varlist [if exp] [in range] [, allobs percent ]

firstdigit varname [if exp] [in range] [, by(byvar) missing percent ]

by ... : may also be used with firstdigit: see help on by.

Description

firstdigit tabulates and analyses the first digits of numeric variables. It also tests Benford's law that digits d = 1,..,9 occur with probabilities log10(1 + 1/d). Thus given data of 12, 345, 6789, etc., it would extract 1, 3, 6, etc., tabulate the frequencies of the digits 1 to 9 and give a chi-square test of the law. Use return list to see returned results.

Options

allobs specifies use of the maximum possible number of observations for each variable. The default is to use only those observations for which all variables in varlist are not missing.

by() specifies a variable defining distinct groups for which statistics should be calculated. by() is allowed only with a single varname. The choice between by: and by() is partly one of precisely what kind of output display is required. The display with by: is clearly structured by groups while that with by() is more compact. To show statistics for several variables and several groups with a single call to firstdigit, the display with by: is essential.

missing specifies that with the by() option observations with missing values of byvar should be included in calculations. The default is to exclude them.

percent specifies that observed and expected frequency distributions should be shown as percents. This naturally has no effect on the chi-square test which is carried out on the frequencies themselves.

Examples

. firstdigit myvar . firstdigit myvar, percent

Author

Nicholas J. Cox, Durham University n.j.cox@durham.ac.uk