Dear Statalist
I'm using version 16.1.
I have used a bayesian method for estimation of diasease prevalence and the accuracy of diagnostic tests. The method is widely used (500+ citations), however I did not find any standard STATA command or user-written commands to apply the method in my favorite stitiscal software, STATA. I have therefore written it myself using program define in a do-file. The code works well and produce correct results.
Now I want to write the program more generic, save it as an ado-file, and ultimately make it availble for others as a user-written command. I have followed the STATA PDF manual om programming.
I would like the following syntax (I call the command nogoldone):
nogoldone a b alpha_prev beta_prev alpha_sn beta_sn alpha_sp beta_sp , sims() burnin() graph detail bdpar
where
a b are numerical arguments restricted to contain an integer
alpha_prev beta_prev alpha_sn beta_sn alpha_sp beta_sp numerical arguments - if possible with default values = 1
sims() burnin() are optional options with the default values = 25000 and 5000, respectively
graph detail and bdpar are optional options
I have read the manual on the syntax command, but can't find out how to do this.
y best guees so far have been something like:
Currently in the program I just do it like this, i.e. calls the numerical arguments from `1' [...] `8' and call the options sims() and burnin() from ´9' and `10' .
When I have the graph detail and bdpar options I will use it like this
Hope you can guide me on how to
1) write the syntax command
2) call the arguments in the code
Best regards
Esben Eriksen
University of Copenhagen
I'm using version 16.1.
I have used a bayesian method for estimation of diasease prevalence and the accuracy of diagnostic tests. The method is widely used (500+ citations), however I did not find any standard STATA command or user-written commands to apply the method in my favorite stitiscal software, STATA. I have therefore written it myself using program define in a do-file. The code works well and produce correct results.
Now I want to write the program more generic, save it as an ado-file, and ultimately make it availble for others as a user-written command. I have followed the STATA PDF manual om programming.
I would like the following syntax (I call the command nogoldone):
nogoldone a b alpha_prev beta_prev alpha_sn beta_sn alpha_sp beta_sp , sims() burnin() graph detail bdpar
where
a b are numerical arguments restricted to contain an integer
alpha_prev beta_prev alpha_sn beta_sn alpha_sp beta_sp numerical arguments - if possible with default values = 1
sims() burnin() are optional options with the default values = 25000 and 5000, respectively
graph detail and bdpar are optional options
I have read the manual on the syntax command, but can't find out how to do this.
y best guees so far have been something like:
Currently in the program I just do it like this, i.e. calls the numerical arguments from `1' [...] `8' and call the options sims() and burnin() from ´9' and `10' .
Code:
program define nogoldone , rclass version 16 quietly { preserve tempfile simudat tempvar y1 y2 π s c save "`simudat'", emptyok use "`simudat'", clear set obs `9' tempname a b απ βπ αs βs αc βc p_alpha p_beta s_alpha s_beta c_alpha c_beta sca define `a' = `1' sca define `b' = `2' scalar define `απ' = `3' scalar define `βπ' = `4' scalar define `αs' = `5' scalar define `βs' = `6' scalar define `αc' = `7' scalar define `βc' = `8' gen `y1' =. gen `y2'=. gen `π'=. gen `s' =. gen `c'=. label variable `π' "Prevalence" label variable `s' "Sensitivity" label variable `c' "Specificity" replace `y1'= rbinomial(`a', 0.5) in 1 replace `y2'= rbinomial(`b', 0.5) in 1 [some more code calling the scalars `απ' `βπ' `αs' `βs' `αc' `βc' ] forvalues i= 2/`9' [some more code running simulations ] drop in 1/`10' } some code generating output, graphs, detailed output and beta distrubution parameters as output end
When I have the graph detail and bdpar options I will use it like this
Code:
if detail { [some code generating detailed rather than simple estimates as output] } if graph { [some code generating graphs as ouput] } if bdpar { [some code generating estimates of beta distrubution parameters as output] }
Hope you can guide me on how to
1) write the syntax command
2) call the arguments in the code
Best regards
Esben Eriksen
University of Copenhagen
Comment