Dear Statalists,
I want to study the effect of a treatment on my outcome in different subpopulations of my sample (e.g. male-female, young-old) and I would like to represent the results in a single forest plots including odds ratio and 95% C.I. from all the univariate logistic regressions, to allow comparison. I thought about using metan command for the forest plot, but I would need to produce a dataset with variables' names, variables' categories names, odds ratios and C.I. to do it.
However, the most I could do so far was producing a matrix with numbers indicating categories of categorical variables, or and lower and upper bound for C.I. using the following code:
foreach var in age gender region placeresidence education {
levelsof(`var'), local(levels`var')
foreach l of local levels`var' {
logit y_kid_01 i.Treatchild_enc if children_018==1 & `var'==`l', or vce(cluster ResponseId)
matrix tbl=r(table)
matrix mytbl=nullmat(mytbl)\[`l',tbl["b","y_kid_01:1.Treatchild_enc"],tbl["ll","y_kid_01:1.Treatchild_enc"],tbl["ul","y_kid_01:1.Treatchild_enc"]]
}
}
matrix colname mytbl= category or ul ll
matrix list mytbl
Is there a way to add a column for variable names and to label the variables' categories? Or is there a better/more efficient way to plot the graph?
Thank you very much in advance!
I want to study the effect of a treatment on my outcome in different subpopulations of my sample (e.g. male-female, young-old) and I would like to represent the results in a single forest plots including odds ratio and 95% C.I. from all the univariate logistic regressions, to allow comparison. I thought about using metan command for the forest plot, but I would need to produce a dataset with variables' names, variables' categories names, odds ratios and C.I. to do it.
However, the most I could do so far was producing a matrix with numbers indicating categories of categorical variables, or and lower and upper bound for C.I. using the following code:
foreach var in age gender region placeresidence education {
levelsof(`var'), local(levels`var')
foreach l of local levels`var' {
logit y_kid_01 i.Treatchild_enc if children_018==1 & `var'==`l', or vce(cluster ResponseId)
matrix tbl=r(table)
matrix mytbl=nullmat(mytbl)\[`l',tbl["b","y_kid_01:1.Treatchild_enc"],tbl["ll","y_kid_01:1.Treatchild_enc"],tbl["ul","y_kid_01:1.Treatchild_enc"]]
}
}
matrix colname mytbl= category or ul ll
matrix list mytbl
Is there a way to add a column for variable names and to label the variables' categories? Or is there a better/more efficient way to plot the graph?
Thank you very much in advance!
Comment