Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Suppress unused values of categorical var in graph? (Stata 11) |
Date | Mon, 15 Aug 2011 12:51:00 +0100 |
Looks the same to me. Where did you get it from? On Mon, Aug 15, 2011 at 12:44 PM, Kaulisch, Marc <kaulisch@forschungsinfo.de> wrote: > It is -revv-. > > Marc > > -----Ursprüngliche Nachricht----- > Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nick Cox > Gesendet: Montag, 15. August 2011 10:11 > An: statalist@hsphsun2.harvard.edu > Betreff: Re: st: Suppress unused values of categorical var in graph? (Stata 11) > > I can't find a -rew- on SSC. > > Nick > > On Sun, Aug 14, 2011 at 8:37 PM, Kaulisch, Marc <kaulisch@forschungsinfo.de> wrote: >> In order to keep the same order of the categorical variables on the graph as I would get with -ciplot- (from ssc) I add another line to the code, using the -revv- command (from ssc): >> >> egen group = group(for_eu), label >> revv group, gen(groupa) >> twoway rcap ub lb groupa, hori || scatter groupa mean, /// >> legend(off) ytitle("") ylabel(1/5, valuelabel angle(0) nogrid) >> >> Marc >> >> -----Ursprüngliche Nachricht----- >> Von: owner-statalist@hsphsun2.harvard.edu >> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Kaulisch, >> Marc >> Gesendet: Sonntag, 14. August 2011 21:23 >> An: statalist@hsphsun2.harvard.edu >> Betreff: AW: st: Suppress unused values of categorical var in graph? >> (Stata 11) >> >> Nick, >> Stupid me, haven't thought about that solution because I used "egen group" only with two or more vars... Your solution is very handsome. >> Of course, my problem is self-inflicted but in some cases it is useful that values of categorical variables are not equally spaced. >> >> Marc >> >> -----Ursprüngliche Nachricht----- >> Von: owner-statalist@hsphsun2.harvard.edu >> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nick Cox >> Gesendet: Sonntag, 14. August 2011 17:53 >> An: statalist@hsphsun2.harvard.edu >> Betreff: Re: st: Suppress unused values of categorical var in graph? >> (Stata 11) >> >> Marc's problem could be regarded as self-inflicted. He creates a variable with values 1, 4, 6, 8, 12 and then complains that the values when supplied as one axis of a -twoway graph- are not plotted with equal spacing. >> >> More seriously: Marc's problem is certainly that -twoway- has no notion of a categorical variable. However, two more lines of code produce equal spacing: >> >> egen group = group(for_eu), label >> twoway rcap ub lb group, hori || scatter group mean, /// >> legend(off) ytitle("") ylabel(1/5, valuelabel angle(0) nogrid) >> >> I'll look into the problem with -ciplot- reported by Marc. >> >> Nick >> >> On Sun, Aug 14, 2011 at 1:02 PM, Kaulisch, Marc <kaulisch@forschungsinfo.de> wrote: >>> I came across a problem with -ciplot- (from ssc) because option >>> ytitle("") does not suppress the ytitle. As Nick Cox (author of >>> ciplot) mentioned earlier that he does not touch ciplot anymore and >>> one should use the statsby strategy (see Stata Journal 10, 1, >>> p.143-151). I started to follow his advise but come to a point of >>> dissatification and maybe some one can help me (still Stata 11 user). >>> >>> I have a categorical variable with categories ranging from 8 to 44 >>> where some values in this range are not attached to any categories. >>> Drawing a graph means that on the axis of this variable there is a lot of "unused" >>> space. Is there a way to reduce this? Is there a way to tell Stata >>> that this is a categorical variable (factor variables are not allowed...)? >>> (Of course a recode of the cat var would do the trick but why should >>> this be the only option?) >>> >>> My example code with the auto dataset >>> >>> sysuse auto >>> recode foreign (0=1) (1=4), gen(for_eu) replace for_eu = 6 if >>> regexm(make, "Renault") replace for_eu = 8 if regexm(make, "VW") >>> replace for_eu = 12 if regexm(make, "Audi") statsby mean=r(mean) >>> ub=r(ub) lb=r(lb) N=r(N), clear by(for_eu): ci weight levelsof >>> for_eu, >>> local(fe) twoway rcap ub lb for_eu, hori || scatter for_eu mean, /// >>> legend(off) ytitle("") ylabel(`fe', valuelabel angle(0) nogrid) >>> * * 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/