Hi all,
How could we plot a graph like this in Stata?
How could we plot a graph like this in Stata?
clear input str5 agegrp float(rr lower higher) "18-20" 1 .81 8.56 "21-25" 2.63 .82 8.45 "26-30" 2.64 .88 9.37 "31-35" 2.87 .97 10.3 "36-40" 3.16 .83 9.8 "41-45" 2.86 1.65 17.24 "46-50" 5.33 .96 11.55 "51-55" 3.33 .38 7.92 "56-60" 1.74 1.33 16.66 "61-65" 4.71 1.27 18.52 "66-70" 4.85 .03 22 end split agegrp, parse("-") gen(age) destring gen age = (age1+age2)/2 graph twoway (scatter age rr ) (rcap lower higher age, horizontal)
ssc describe coefplot
webuse bcgset, clear gen label= author +","+ string(year) mkmat _meta_es _meta_cil _meta_ciu, mat(res) rownames(label) *WEIGHTING VAR SHOULD BE PRESENT set seed 08162025 gen wvar= runiformint(1, 7) mat list res mat res= res' coefplot mat(res), ci((res[2] res[3])) weight(wvar) rename(\_et\_al\_ = " et al." _&_ = " & ", regex)
. mat list res res[13,3] _meta_es _meta_cil _meta_ciu Aronson,1948 -.88931133 -2.0076675 .22904481 Ferguso~1949 -1.5853887 -2.4499552 -.72082208 Rosenth~1960 -1.3480731 -2.6112513 -.08489504 Hart_&_~1977 -1.4415512 -1.7188015 -1.1643009 Frimodt~1973 -.21754732 -.6610806 .22598595 Stein_&~1953 -.78611559 -.94898869 -.62324248 Vandivi~1973 -1.6208982 -2.5464854 -.69531107 TPT_Mad~1980 .01195233 -.11140991 .13531458 Coetzee~1968 -.46941765 -.93502445 -.00381085 Rosenth~1961 -1.3713448 -1.9009878 -.84170178 Comstoc~1974 -.33935883 -.55771864 -.12099901 Comstoc~1969 .4459134 -.98433108 1.8761579 Comstoc~1976 -.01731395 -.54104867 .5064207
. which coefplot C:\~\ado\plus\c\coefplot.ado *! version 1.8.6 22feb2023 Ben Jann
webuse bcgset, clear gen label= author +","+ string(year) *WEIGHTING VAR SHOULD BE PRESENT set seed 08162025 gen wvar= runiformint(1, 7) mkmat _meta_es _meta_cil _meta_ciu wvar, mat(res) rownames(label) mat list res mat res= res' coefplot mat(res), ci((res[2] res[3])) aux(res[4]) weight(@aux) rename(_et_al_ = " et al." _&_ = " & " "_" = " ", regex)
. mat list res res[13,4] _meta_es _meta_cil _meta_ciu wvar Aronson,1948 -.88931133 -2.0076675 .22904481 1 Ferguso~1949 -1.5853887 -2.4499552 -.72082208 4 Rosenth~1960 -1.3480731 -2.6112513 -.08489504 1 Hart_&_~1977 -1.4415512 -1.7188015 -1.1643009 5 Frimodt~1973 -.21754732 -.6610806 .22598595 6 Stein_&~1953 -.78611559 -.94898869 -.62324248 5 Vandivi~1973 -1.6208982 -2.5464854 -.69531107 2 TPT_Mad~1980 .01195233 -.11140991 .13531458 7 Coetzee~1968 -.46941765 -.93502445 -.00381085 1 Rosenth~1961 -1.3713448 -1.9009878 -.84170178 7 Comstoc~1974 -.33935883 -.55771864 -.12099901 1 Comstoc~1969 .4459134 -.98433108 1.8761579 7 Comstoc~1976 -.01731395 -.54104867 .50642077 3
webuse bcgset, clear gen label= author +","+ string(year) *WEIGHTING VAR SHOULD BE PRESENT set seed 08162025 gen wvar= runiformint(1, 7) forval i = 1/ 7 { mkmat _meta_es _meta_cil _meta_ciu if wvar == `i', mat(res`i') rownames(label) mat res`i' = res`i'' } forval i = 1/7 { local plotcmd `plotcmd' (mat(res`i'), ci((res`i'[2] res`i'[3])) msize(`i') label(`i') ) } coefplot `plotcmd' , /// rename(_et_al_ = " et al." _&_ = " & " "_" = " ", regex) /// format(%4.3f) /// legend(title("Lesion Count")) /// mlabel mlabpos(2) mc(stc1) /// ciopts(lcolor(stc1))
webuse bcgset, clear gen label= author +","+ string(year) *WEIGHTING VAR SHOULD BE PRESENT set seed 08162025 gen wvar= runiformint(1, 7) sort _meta_es label mkmat _meta_es _meta_cil _meta_ciu, mat(res0) rownames(label) mat res0= res0' forval i = 1/ 7 { mkmat _meta_es _meta_cil _meta_ciu if wvar == `i', mat(res`i') rownames(label) mat res`i' = res`i'' } forval i = 1/7 { local plotcmd `plotcmd' (mat(res`i'), ci((res`i'[2] res`i'[3])) msize(`i') label(`i') mlabc(stc1) ) } coefplot (mat(res0), ci((res0[2] res0[3])) ciopts(lc(none)) mc(none) mlabc(none)) `plotcmd' , /// rename(_et_al_ = " et al." _&_ = " & " "_" = " ", regex) /// format(%4.3f) /// legend(order(4 6 8 10 12 14 16) title("Lesion Count")) /// mlabel mlabpos(2) mc(stc1) /// ciopts(lcolor(stc1))
webuse bcgset, clear gen label= author +","+ string(year) *WEIGHTING VAR SHOULD BE PRESENT set seed 08162025 gen wvar= runiformint(1, 7) sort label mkmat _meta_es _meta_cil _meta_ciu, mat(res0) rownames(label) mat res0 = res0' forval i = 1/ 7 { mkmat _meta_es _meta_cil _meta_ciu if wvar == `i', mat(res`i') rownames(label) mat res`i' = res`i'' local plotcmd `plotcmd' (mat(res`i'), ci((res`i'[2] res`i'[3])) msize(`i') label(`i') offset(0)) } coefplot /// (mat(res0) , noci mc(none) mlabc(none) nokey) /// `plotcmd' , /// rename(_et_al_ = " et al." _&_ = " & " "_" = " ", regex) /// format(%4.3f) /// legend(title("Lesion Count")) /// mlabel mlabpos(2) mc(stc1) /// ciopts(lcolor(stc1))
. drop _all . set obs 10 Number of observations (_N) was 0, now 10. . drawnorm x y . gen wvar = . (10 missing values generated) . twoway (scatter x y [aw=wvar]) r(198);
Comment