# st: R: Monte Carlo simulations

 From "Carlo Lazzaro" To Subject st: R: Monte Carlo simulations Date Sat, 26 Jul 2008 13:17:20 +0200

```Dear Dave,
provided that I am not that clear with what you mean with "level of
concurrency", I have tried to propose a solution to your problem via a
fictitious prevalence data for both HIV (10/10000) and TB (5/10000),
assuming that you are interested in random sampling from your original data
set on the prevalence of HIV and TB.
Assuming prevalence data can be modelled following a binomial distribution
in the base case analysis, you can perform a Monte Carlo simulation for
sensitivity analysis purpose(even without invoking the -simulate- command)
via an Inverse beta distribution)(please, see for reference Spiegelhalter
DJ, Abrams KR, Myles JP. Bayesian Approaches to Clinical Trials and
Health_Care Evaluation. Chichester: Wiley, 2004: 36-37; 58-62; Briggs A.
Schulper M, Claxton K. Decision Modelling for Health Economic Evaluation.
Oxford: Oxford University Press, 2006: 86-89).
Please find below how to construct the alfa and beta parameters of a beta
distribution for both HIV and TB prevalences.
Then you can draw 10,000 random values for both HIV and TB prevalence via
two inverse cumulative Beta distributions.

HTH and Kind Regards,
Carlo

log using "C:\Documents and
Settings\carlo\Documenti\Statistiche\Stata\Dave.smcl", replace
set obs 10000
g Prev_HIV=10/10000
g Prev_TB=5/10000
cii 10000 10
cii 10000 5
g SE_Prev_HIV= .0003161
g SE_Prev_TB=  .0002236
g Alfa_Prev_HIV=(.001^2*(10000-10)/.0003161)-.001
g Beta_Prev_HIV= Alfa_Prev_HIV*(1- .001)/ .001
g Alfa_Prev_TB=(.0005^2*(10000-5)/.0002236 )-.0005
g Beta_Prev_TB=  Alfa_Prev_TB*(1- .0005)/.0005
g Inv_Beta_HIV_Prev=invibeta( Alfa_Prev_HIV, Beta_Prev_HIV,uniform())
drop Inv_Beta_HIV_Prev
g Inv_Beta_HIV_Prev=invibeta( Alfa_Prev_HIV, Beta_Prev_HIV,uniform())
g Inv_Beta_TB_Prev=invibeta(  Alfa_Prev_TB,  Beta_Prev_TB,uniform())

-----Messaggio originale-----
Da: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di D Harwood
Inviato: venerd́ 25 luglio 2008 16.32
A: statalist@hsphsun2.harvard.edu
Oggetto: st: Monte Carlo simulations

Hi all,

I have been trying to run a Monte Carlo simulation to estimate the
level of concurerency between two variables, HIV prevalence and TB
prevalence. However I have struggled to do this, does anyone have any
tips on how to use the simulate command? Or even any ideas of how this
may be done better using a different command?

Thanks,

Dave.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```