НачатьНачать бесплатно

Conformity of census data

Before using Benford's law, it's important to check whether your dataset conforms to Benford's law. The dataset census.2009 contains the populations of 19509 towns and cities of the United States (July 2009) and was used in Nigrini, M. J. (2012). Benford’s Law: Application for Forensic Accounting, Auditing and Fraud Detection. Wiley and Sons: New Jersey. Let's test if the populations in 2009 satisfy Benford's law.

The plots will show the graphs and the legends separately, click Previous Plot to check the graphs.

Это упражнение является частью курса

Fraud Detection in R

Посмотреть курс

Инструкции к упражнению

  • Load the benford.analysis package.
  • Check the conformity of the variable pop.2009 to Benford's Law distribution of the first digit. Note that we only look at the first plot that is produced. The other plots are outside the scope of this course.
  • Multiply the variable pop.2009 by 3 and check the conformity again.

Интерактивное практическое упражнение

Попробуйте выполнить это упражнение, дополнив этот пример кода.

# Load package benford.analysis
library(___)
data(census.2009)

# Check conformity
bfd.cen <- benford(___$___, number.of.digits = ___) 
plot(bfd.cen, except = c("second order", "summation", "mantissa", "chi squared","abs diff", "ex summation", "Legend"), multiple = F) 

# Multiply the data by 3 and check conformity again
data <- census.2009$pop.2009 * ___
bfd.cen3 <- benford(___, number.of.digits=___)
plot(bfd.cen3, except = c("second order", "summation", "mantissa", "chi squared","abs diff", "ex summation", "Legend"), multiple = F)
Редактировать и запускать код