Skip to content

R vs. Stata benchmark

Uses https://github.com/prehensilecode/benchmark-stata-r/tree/slurm modified from the original by Matthieu Gomez.

Details

  • R uses the packages data.table, fst, and fixest
  • Stata uses the gtools, ftools, and autorename modules

Generate data sets

Generate data sets with the R script: 1-generate-datasets.r

Modify benchmark code

Need to set number of threads/cores for both the R and Stata code.

In 2-benchmark-r.r:

# setting options -- mc.cores may not be necessary: R should automatically use all cores that it can see
options(mc.cores=48)
setFixest_nthreads(48)

In 3-benchmark-stata.do:

/* benchmark */
set processors 48

Picotte Results

Bars to the right indicate that R is faster than Stata. Bars to the left indicate that Stata is faster than R.

border|800px

See Also