Skip to contents

Monte Carlos

The Burr example

The helper function is beyondpareto_Burrsim, and we run the Monte Carlo in parallel mode using parallel with 6 clusters. In serial mode, the MC based on 1,000 repetitions takes about 75 minutes. In the following, note that set seed 330033 does not lead to exactly identical results because of the way parallel deals with this.

DPG: The Burr distribution with \(\gamma=.6\) and \(\rho=-2\).

* serial call:
* simulate k=e(kbase) gamma=e(gamma), reps(2) nodots: beyondpareto_Burrsim

parallel setclusters 6

* set seed 330033   
local ttime1 = clock(c(current_time), "hms")    

parallel sim, reps(1000) expr(k=e(kbase) gamma=e(gamma)) nodots: beyondpareto_Burrsim

local ttime2 = clock(c(current_time), "hms")
local dtime = Clockdiff(`ttime1', `ttime2', "second") / 60
di "run time in minutes: `dtime'"

sum

parallel clean
run time in minutes: 8.133333333333333

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
           k |      1,000    2545.241    712.8709       1001       4302
       gamma |      1,000    .6070763    .0179436    .548443    .650344

The GB2 example

For this case the helper is beyondpareto_GB2sim.

DGP: \(\gamma=.37927346\).

clear all

parallel setclusters 6

set seed 330033 
local ttime1 = clock(c(current_time), "hms")    

parallel sim, reps(1000) expr(k=e(kbase) gamma=e(gamma)) nodots: beyondpareto_GB2sim

local ttime2 = clock(c(current_time), "hms")
local dtime = Clockdiff(`ttime1', `ttime2', "second") / 60
di "run time in minutes: `dtime'"

sum

parallel clean
run time in minutes: 5.75


    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
           k |      1,000    2117.419    570.0305       1000       3641
       gamma |      1,000    .3847046    .0120914   .3319991   .4169914

Session Information

display "STATA version: `c(stata_version)' running on `c(os)' `c(osdtl)' "
STATA version: 18 running on MacOSX 14.1.0 
which parallel
/Users/christianschluter/Library/Application Support/Stata/ado/plus/p/parallel.ado
*! version 1.15.8.19  19agol2015
*! PARALLEL: Stata module for parallel computing
*! by George G. Vega [cre,aut], Brian Quistorff [ctb]
*! 
*! Project website: 
*!   https://github.com/gvegayon/parallel
*! Bug reports:
*!   https://github.com/gvegayon/parallel/issues
which beyondpareto_Burrsim
/Users/christianschluter/Documents/Stata/ado/personal/beyondpareto_Burrsim.ado
*! part of the beyondpareto suite