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

From |
Roy Wada <roywada@hotmail.com> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: Graphing table of odds ratios generated by e.g., gologit2 |

Date |
Fri, 17 Jul 2009 09:53:51 -0700 |

Thanks, Nick. Dropping variables will not bite since -preserve- is applied, but it is a poor programming style. A better way is to give labels to temp variables, which would have prevented them from showing up on the axis. The passthru options did occur to me when I started thinking about the color. I twisted it so it is now available for the scatter graph, for the qfit graph, and for both graphs (the twoway). The program now comes with options for saving the graph points should someone wants to make a graph on their own. An interesting extension is to make a similar graph across estimates, sort of like a graphic version of a regression table. It should be useful when CI is added. Feel free to chime in if someone has suggestions. If anyone knows how to pass the label values to the graph values (replace 1, 2, etc, with value labels on the axis), I would be interested. Roy sysuse auto, clear reg3 (price mpg) (price mpg rep78) (price mpg rep78 headroom) (price mpg rep78 headroom length) paragr mpg, qfit(xtitle(X-Axis Title)) scatter(mcolor(blue)) title(Big Title) eq(myeq) coef(mycoef) *! paragr 1.0.1 16Jul2009 by roywada@hotmail.com *! parallel graphing of a coefficient across different equations prog define paragr version 8.0 syntax varlist(min=1 max=1) [, qfit QFIT2(str asis) SCATter(str asis) EQsave(string) COEFsave(string) *] local var `varlist' qui { tempname coef coefficient equation mat `coef'=e(b) local eqlist : coleq `coef' local eqlist: list clean local(eqlist) local eqlist: list uniq local(eqlist) local eqnum: word count `eqlist' gen `equation'=_n gen `coefficient'=. forval num=1/`eqnum' { local name: word `num' of `eqlist' cap mat temp`num'=`coef'[1,"`name':`var'"] if _rc==0 { local temp`num'=temp`num'[1,1] replace `coefficient'=`temp`num'' in `num' } else { replace `coefficient'=. in `num' } * quantile stuff if "`e(cmd)'"=="qreg" | "`e(cmd)'"=="iqreg" | "`e(cmd)'"=="sqreg" | "`e(cmd)'"=="bsqreg" { local tempname=subinstr("`name'","q",".",.) replace `equation'=`tempname' in `num' } } * labels label var `equation' "Equations" if "`e(cmd)'"=="qreg" | "`e(cmd)'"=="iqreg" | "`e(cmd)'"=="sqreg" | "`e(cmd)'"=="bsqreg" { label var `equation' "Quantiles" } local content: var label `var' label var `coefficient' "`content'" label define vallab 0 "no" 1 "yes" label val `equation' vallab if "`qfit'"=="" & "`qfit2'"=="" { twoway (scatter `coefficient' `equation' in 1/`eqnum', `scatter'), `options' } else { twoway (scatter `coefficient' `equation' in 1/`eqnum', `scatter') /* */ (qfit `coefficient' `equation' in 1/`eqnum', `qfit2' ), `options' } * save variables if "`eqsave'"~="" { local N=_N replace `equation'=. in `=`eqnum'+1'/`N' gen `eqsave'=`equation' } if "`COEFsave'"~="" { gen `COEFsave'=`coefficient' } } /* quiet */ end exit > 1. The program works with variables -coefficient- and -equation-, > -drop-ping any existing instance of either variable. This is not > necessary and often considered to be poor Stata programming style. > > 2. The options -xlabel()- and -ylabel()- are used in non-standard ways. > In a Stata graphics context these always mean axis labels, not axis > titles. (I do realise that "axis label" often means elsewhere what Stata > takes to be axis title, but Stata conventions are what count in Stata.) > > 3. Any serious user of a graphics program will want to reach through and > tune any detail of the graph. This is at present only possible through > the Graph Editor. > > 4. The qualifier -in 1/`eqnum'- will be faster than -if _n <= `eqnum'-. > > 5. -replace-ing missings by missings is unnecessary. > _________________________________________________________________ Lauren found her dream laptop. Find the PC that’s right for you. http://www.microsoft.com/windows/choosepc/?ocid=ftp_val_wl_290 * * 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/

**Follow-Ups**:**RE: st: Graphing table of odds ratios generated by e.g., gologit2***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: Graphing table of odds ratios generated by e.g., gologit2***From:*John LeBlanc <leblancj@dal.ca>

**RE: st: Graphing table of odds ratios generated by e.g., gologit2***From:*Roy Wada <roywada@hotmail.com>

**RE: st: Graphing table of odds ratios generated by e.g., gologit2***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: Missing indicator method for partially mising baseline measurements in randomized trials** - Next by Date:
**RE: st: Graphing table of odds ratios generated by e.g., gologit2** - Previous by thread:
**Re: st: Graphing table of odds ratios generated by e.g., gologit2** - Next by thread:
**RE: st: Graphing table of odds ratios generated by e.g., gologit2** - Index(es):

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