Hi Listers,
I am running a series of subgroup analysis for specific demographics; all very exploratory so I would like to present the results as a Forest plot. I am using metan but the final plot could do with some tweaking. Here is an example using Stata available data.
I would like to 1) remove the title on the top left corner "name and subgroup"; 2) indent the groups, indepent "47-54" and 55+" in relation to the word Age; 3) remove the 5 for the last row of the graph and just have it read All participants; 4) is there any way to specify the xscale as I could not get it to work.
Any suggestions on how to achieve this in metan; or perhaps a better way?
I am running a series of subgroup analysis for specific demographics; all very exploratory so I would like to present the results as a Forest plot. I am using metan but the final plot could do with some tweaking. Here is an example using Stata available data.
I would like to 1) remove the title on the top left corner "name and subgroup"; 2) indent the groups, indepent "47-54" and 55+" in relation to the word Age; 3) remove the 5 for the last row of the graph and just have it read All participants; 4) is there any way to specify the xscale as I could not get it to work.
Any suggestions on how to achieve this in metan; or perhaps a better way?
Code:
* 1. Load data
sysuse cancer, clear
stset studytime, failure(died)
recode drug (2/3=2)
* 2. Initialize postfile
tempname memhold
tempfile results
postfile `memhold' str20(name) str20(subgroup) hr lci uci using `results', replace
tab age
capture drop agecat
egen agecat = cut(age), at(47, 55, 68)
la de agecatlb 47 "47-54" 55 "55+", modify
la val agecat agecatlb
tab age agecat
set seed 1245
g sex = runiform()>=0.5
tab sex
la de sexlb 0 "Male" 1 "Female", modify
la val sex sexlb
* 3. Run Cox models for age
levelsof agecat, local(a_levels)
foreach a in `a_levels' {
local aname : label (agecat) `a'
stcox i.drug if agecat == `a'
matrix b = r(table)
post `memhold' ("Age") ("`aname'") (b[1,2]) (b[5,2]) (b[6,2])
}
* 4. Run Cox models for sex
* Note: drug effect within each sex
levelsof sex, local(s_levels)
foreach s in `s_levels' {
local sname : label (sex) `s'
stcox i.drug if sex == `s'
matrix b = r(table)
post `memhold' ("Sex") ("`sname'") (b[1,2]) (b[5,2]) (b[6,2])
}
*5 - Cox for all participants
stcox i.drug
matrix b = r(table)
matrix list b
post `memhold' ("ALL") (" ") (b[1,2]) (b[5,2]) (b[6,2])
postclose `memhold'
* 5. Load and Prep for Plotting
use `results', clear
metan hr lci uci, label(namevar=subgroup) by(name) ///
nosub nooverall xtitle("HR") effect(HR) xline(1)

Comment