Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: How to plot ORs and CI - results of a logistic regression


From   "Roger B. Newson" <r.newson@imperial.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to plot ORs and CI - results of a logistic regression
Date   Sun, 01 Jul 2012 20:53:48 +0100

I suspect that you have an out-of-date version of -sdecode-. If your current version of Stata is Version 11 or higher, then you should update -sdecode- (and -bmjcip-) to the most recent version downloadable from SSC.

I hope this helps. Let me know if it doesn't.

Best wishes

Roger

Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton Campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: r.newson@imperial.ac.uk
Web page: http://www.imperial.ac.uk/nhli/r.newson/
Departmental Web page:
http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/

Opinions expressed are those of the author, not of the institution.


On 01/07/2012 20:41, Sofia Ramiro wrote:
Thank you very much for your hel, Roger.
The first part worked very well and now I manage to include the variable labels, thanks!
however, I got some problems with the 2nd part

. bmjcip S_1 S_2 S_3, cformat(%8.2f)
option ftrim not allowed

I still tried using other cformats and even xmlsub, but none of them worked.
Can you please help me?

thanks!

Sofia

----------------------------------------
Date: Sun, 1 Jul 2012 20:12:14 +0100
From: r.newson@imperial.ac.uk
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: How to plot ORs and CI - results of a logistic regression

To reconstruct the variable labels into a variable with value labels,
use the -label- option of -parmest-, together with the -sencode-
package, which you can also download from SSC, and which is a "super"
version of -encode-. As in:

#delim ;
logistic asdasimprov3M1 asdascalc male num_anos_escolaridade
eva_total_colunaconvhighlow4;
parmest, norestore eform label;
sencode label, gene(parmlab);
twoway scatter parmlab estimate,
xline(1) ylab(, valuelabel angle(0)) ||
rcap min95 max95 parmlab, horizontal
legend(order(1 "point estimate"
2 "95% conf. int.") pos(6))
xlabel(0(1)8) xtitle("Odds Ratio") ytitle("");

And, if you want to print the estimates and confidence limits on the
right-hand side of the graph, then you can download the -sdecode- and
-bmjcip- packages from SSC, and use those. (-sdecode- is a "super"
version of -decode-, and -bmjcip- is a front end for -sdecode-.) As in:

#delim ;
logistic asdasimprov3M1 asdascalc male num_anos_escolaridade
eva_total_colunaconvhighlow4;
parmest, norestore eform label;
sencode label, gene(parmlab);
clonevar S_1=estimate;
clonevar S_2=min95;
clonevar S_3=max96;
bmjcip S_1 S_2 S_3, cformat(%8.2f);
gene confint=S_1+" "+S_2+" "+S_3;
sencode confint, many replace;
twoway scatter parmlab estimate,
xline(1) ylab(, valuelabel angle(0)) yaxis(1) ||
rcap min95 max95 confint, horizontal yaxis(2) || ,
legend(order(1 "point estimate"
2 "95% conf. int.") pos(6))
xlabel(0(1)8) xtitle("Odds Ratio") ytitle("");

This should give the confidence intervals for the odds ratios on the
right-hand axis to 2 decimal places. (Let me know if it doesn't.)

Best wishes

Roger


Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton Campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: r.newson@imperial.ac.uk
Web page: http://www.imperial.ac.uk/nhli/r.newson/
Departmental Web page:
http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/

Opinions expressed are those of the author, not of the institution.


On 01/07/2012 19:13, Sofia Ramiro wrote:
Dear Statalist members,

I am trying to plot the results of a logistic regression. I would like to have a graph with the ORs and 95%CI plotted.
On the y-axis I would like to include the label of the variables names and, ideally (if possible), I would like to add, on the right hand side of the graph, the ORs and 95%CI written (just as we see for the forrest plots in a meta-analysis).
Having reviewed what as been written on this topic on statalist, this is what I did:

logistic asdasimprov3M1 asdascalc male num_anos_escolaridade eva_total_colunaconvhighlow4
parmest, norestore eform
egen axis= axis(estimate), label(parm)
twoway scatter axis estimate, ///
xline(1) ylab(, valuelabel angle(0)) || ///
rcap min95 max95 axis, horizontal ///
legend(order(1 "point estimate" ///
2 "95% conf. int.") pos(6)) ///
xlabel(0(1)8) xtitle("Odds Ratio") ytitle("")

My problems are:
- On the y-axis I get the variables' names, but they are abbreviated names for my own use - how do I manage to put there labels - eg instead of male, I would like to have "Male gender (vs. female)" ?
- Is it to possible to create a column on the right hand side of the graph where the ORs and 95%CI are written (in addition to being ploted in the graph)? If yes, how?

thanks!

Sofia

*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/


*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
  		 	   		
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index