Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

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 |
Sun, 14 Aug 2011 16:53:18 +0100 |

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/

**References**:**st: Suppress unused values of categorical var in graph? (Stata 11)***From:*"Kaulisch, Marc" <kaulisch@forschungsinfo.de>

- Prev by Date:
**Re: st: Fama-MacBeth regression** - Next by Date:
**Re: st: Re: Coding Question** - Previous by thread:
**st: Suppress unused values of categorical var in graph? (Stata 11)** - Next by thread:
**st: Coding Question** - Index(es):