Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: graph comparing results of several models after -parmby-

From   "Newson, Roger B" <>
To   <>
Subject   st: RE: graph comparing results of several models after -parmby-
Date   Tue, 17 Oct 2006 21:05:29 +0100

In reply to your second query, the -ylabel()- option has a -valuelabel-
suboption, allowing you to type

ylabel(1 2, valuelabel)

which should cause value labels to be printed. See the online help under

whelp axis_label_options

In reply to your first query, the distance between your 2 CIs will be 1
axis unit. If you want there to be a margin abobe the first one and
below the second one, then use the -range()- suboption of the -yscale()-
axis option, as in

ylabel(1 2, valuelabel) yscale(range(0.5 2.5))

which will produce a margin of half an axis unit at the top and at the
bottom. Soo the online help under

whelp axis_scale_options

You might find the -regaxis- package useful for producing automatic axis
scales in local macros, which you can then use with the
-yscale(range())- and -ylabel()- options. You might possibly also like
to use -eclplot- to produce your forest plots. Both -eclplot- and
-regaxis- can be downloaded from SSC. An example of a Cochrane forest
plot produced using -eclplot- appears in Newson (2006), and uses the
-supby()- option of -eclplot- to produce a diamond symbol for the
summary estimate, and the -estopts()- option to weight the square
symbols for the individual studies by study size.

I hope this helps.



Resultssets, resultsspreadsheets and resultsplots in Stata. Presented at
the 4th German Stata User Meeting, 31 March, 2006. Downloadable from my
website at

Roger Newson
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
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322

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

-----Original Message-----
[] On Behalf Of Michael
Sent: 17 October 2006 19:30
To: Statalist
Subject: st: graph comparing results of several models after -parmby-

I am comparing several different regression models whose results I have 
saved using -parmby-, and then concatenated into one data set using

*run models, adjusted and unadjusted (thanks to Roger Newson's paper)
         tempfile tf1 tf2
         parmby "stcox tcm", lab saving (tf1, replace) idn(1) 
ids(Unadjusted) eform
         parmby "stcox tcm stage", lab saving (tf2, replace) idn(2) 
ids(Adjusted) eform
         dsconcat tf1 tf2
         format estimate min* max* %8.2f
         format p %8.2e
and when* forest plot comparing results (thanks to Scott Merryman)
         encode ids, gen(Model)
         twoway rcap min95 max95 Model if parmseq==1, horizontal 
msize(huge) ///
         xtitle(Hazard Ratio and 95% Confidence Interval, margin(0 0 0
5)) ///
         ytitle(Analysis Method) ylabel( 1 "Adjusted" 2 "Unadjusted", 
angle(h)) ///
          || scatter Model estimate if parmseq==1, msize(medlarge)

How would I modify the rcap/scatter command so that I could adjust the 
vertical distance between plotted whisker bars?
How would I modify the ylabel specification so I could automate the 
labeling without manually typing "adjusted", "unadjusted", etc. (I'm 
planning to compare many different models.)

Best wishes,
Michael McCulloch


Michael McCulloch
Pine Street Foundation
124 Pine Street, San Anselmo, CA 94960-2674
tel     415.407.1357
fax     415.485.1065

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index