------------------------------------------------------------------------------- help forfirstdigit-------------------------------------------------------------------------------

First digits of numeric variables

firstdigitvarlist[ifexp] [inrange] [,allobspercent]

firstdigitvarname[ifexp] [inrange] [,by(byvar)missingpercent]

by ... :may also be used withfirstdigit: see help on by.

Description

firstdigittabulates 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. Usereturn listto see returned results.

Options

allobsspecifies use of the maximum possible number of observations for each variable. The default is to use only those observations for which all variables invarlistare not missing.

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

missingspecifies that with theby()option observations with missing values ofbyvarshould be included in calculations. The default is to exclude them.

percentspecifies 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

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