I have written a code to run the LFK index (Int J Evid Based Healthc. 2018 Dec;16(4):195-203). At the moment it only runs using OR as the effect size but I want to add the options to run it using OR, RR, and RD.
Could someone please point me how to enter the options in the syntax, so I can create different loops to run
admetan `1' `2' `3' `4' , nograph or
admetan `1' `2' `3' `4' , nograph rr
admetan `1' `2' `3' `4' , nograph rd
Many thanks
Luis
Code:
program define lfk, rclass syntax varlist(min=1 max=4 numeric) [if] [in] tempvar a marksample touse, novarlist if "`a'" == "" markout `touse' preserve quietly keep if `touse' ***Data case no_cases if "`3'" != "" & "`4'" != ""{ quietly { admetan `1' `2' `3' `4' , nograph or rename _ES ln_es rename _seES se_es bysort ln_es se_es: gen dup = cond(_N==1,1,_n) gsort -dup ln_es gen dup_max = dup[1] sort ln_es dup gen se_es2 = se_es^2 egen se_es2_max = max(se_es2) gen n = round(((se_es2_max/se_es2)*100),1) gen rank1 = sum(n) if dup ==1 replace rank1 = rank1[_n-1] if rank1==. gen pct1 = rank1[_n-dup_max] replace pct1 = 0 if pct1 ==. gen rank2 = (rank1 + pct1)/2 egen n_sum = sum(n) if dup==1 replace n_sum = n_sum[_n-1] if n_sum==. gen i = (rank2-0.5)/n_sum gen z = invnorm(i) gen z_abs = abs(invnorm(i)) sort z_abs gen es_z_min = ln_es[1] gen es_dif = ln_es - es_z_min sort z gen z_min = z[1] gen z_max = z[_N] sort es_dif gen es_dif_min = es_dif[1] gen es_dif_max = es_dif[_N] gen r = (z_max-z_min) / (es_dif_max-es_dif_min) gen r2 = z + (r*(es_dif)) egen r2_sum = sum(r2) gen _lfk = (5/(2*_N)) * (r2_sum) scalar define lfk = _lfk[1] } ***Report LFK di "" di "" di "LFK index" di "" di _lfk ***Create Doi plot quietly levelsof es_z_min in 1 twoway (connected z_abs ln_es, xline(`r(levels)', lcolor(black) noextend) mcolor(black) msize(vlarge) msymbol(circle) mfcolor(white) lcolor(black) lpattern(shortdash)), ytitle(| Z-score |) ytitle(, size(large)) yscale(reverse) ylabel(, labsize(large) angle(horizontal) labgap(small) nogrid) xtitle(, size(large)) xlabel(, labsize(large) labgap(small)) aspectratio(1.3) graphregion(fcolor(white)) } ***Data theta se_theta if "`3'" == "" & "`4'" == ""{ quietly{ bysort `1' `2': gen dup = cond(_N==1,1,_n) gsort -dup `1' gen dup_max= dup[1] sort `1' dup gen se_es2 = `2'^2 egen se_es2_max = max(se_es2) gen n = round(((se_es2_max/se_es2)*100),1) gen rank1 = sum(n) if dup ==1 replace rank1 = rank1[_n-1] if rank1==. gen pct1 = rank1[_n-dup_max] replace pct1 = 0 if pct1 ==. gen rank2 = (rank1 + pct1)/2 egen n_sum = sum(n) if dup==1 replace n_sum = n_sum[_n-1] if n_sum==. gen i = (rank2-0.5)/n_sum gen z = invnorm(i) gen z_abs = abs(invnorm(i)) sort z_abs gen es_z_min = `1'[1] gen es_dif = `1' - es_z_min sort z gen z_min = z[1] gen z_max = z[_N] sort es_dif gen es_dif_min = es_dif[1] gen es_dif_max = es_dif[_N] gen r = (z_max-z_min) / (es_dif_max-es_dif_min) gen r2 = z + (r*(es_dif)) egen r2_sum = sum(r2) gen _lfk = (5/(2*_N)) * (r2_sum) scalar define lfk = _lfk[1] } ***Report LFK di "" di "" di "LFK index" di "" di _lfk ***Create Doi plot quietly levelsof es_z_min in 1 twoway (connected z_abs `1', xline(`r(levels)', lcolor(black) noextend) mcolor(black) msize(vlarge) msymbol(circle) mfcolor(white) lcolor(black) lpattern(shortdash)), ytitle(| Z-score |) ytitle(, size(large)) yscale(reverse) ylabel(, labsize(large) angle(horizontal) labgap(small) nogrid) xtitle(, size(large)) xlabel(, labsize(large) labgap(small)) aspectratio(1.3) graphregion(fcolor(white)) } * restore quietly gen _lfk = lfk if `touse' ==1 end
0 Response to Adding options to a package (.ado)
Post a Comment