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

From |
Nick Winter <nwinter@virginia.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: graph command: xline() with by() option |

Date |
Wed, 20 Aug 2008 12:49:48 -0400 |

Ooops....read the question too quickly to notice the version 7 reference. So consider this an answer to Nick C's "or even in Stata 10."

--Nick W

Nick Cox wrote:

This is a good idea for Stata 8 up, but won't work in Stata 7, which is

what Achille has.

Nick n.j.cox@durham.ac.uk

Nick Winter

How about something like this? you would need to choose the value of -top- to be the right height, which might require some experimentation. And you might want to add options to the -pcspike- plots to set the line color, etc.

. gen zero = 0

. gen top = 0.05

. graph twoway histogram stat || pcspike zero lower_es top lower_es || pcspike zero upper_es top upper_es , by(grp)

Nick Cox wrote:

sees any references to local macros in commands, it substitutes themUnfortunately, it is possible to say why this doesn't work. When Stata

immediately with their contents and then tries to execute the command.

That applies too to references of formis no way that what you want will be done separately according to the`= <some calculation>'. In short, that is done once only. Thus there

distinct values of a variable specified in a -by()- option.I guess you need to produce individual graphs, and then combine them.Nor can I think of a neat way to do this in Stata 7, or even Stata 10.

-forval- or -foreach- would help.Nick n.j.cox@durham.ac.uk

Achille M. Luongo

I would like to draw a histogram with two vertical lines showing

upper and lower estimates of a statistic for two (or more) groups

usingthe graph command of Stata 7.0.

This is a snippet of the

example dataset:

grp stat lower_es upper_es

1 91 43.45387 60.79625

1 60 43.45387 60.79625

1 87 43.45387 60.79625

1 52 43.45387 60.79625

[..removed..]

2 100 79.70421 124.2349

2 60 79.70421 124.2349

2 77 79.70421 124.2349

2 125 79.70421 124.2349

[..removed..]

I have already read the existing

post at http://www.stata.com/statalist/archive/2003-08/msg00282.html

abouta similar topic. Nevertheless, I can’t figure out how to draw upper and lower estimates with ‘xline()’ option whenthe‘graph’ command is combined with the ‘by’optionlike that:

graph stat, by(grp)

xline(`=lower_es[_n]' `= upper_es[_n]')

In fact, the graph

command always draw vertical lines in the same position in all the

histograms combined with the by option (I suppose it always draws

lower_es[1] and upper_es[1]).

I considered the possibility to

create histograms using the ‘by’ clausole like that:

by grp: graph stat, xline(`=lb[_n]' `=ub[_n]') xlab(0

20 to 140)

but I obtained the the same previous result.

* * 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/

-- -------------------------------------------------------------- Nicholas Winter 434.924.6994 t Assistant Professor 434.924.3359 f Department of Politics nwinter@virginia.edu e University of Virginia faculty.virginia.edu/nwinter w PO Box 400787, 100 Cabell Hall Charlottesville, VA 22904 * * 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: graph command: xline() with by() option***From:*amluongo@rm.unicatt.it

**st: RE: graph command: xline() with by() option***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: RE: graph command: xline() with by() option***From:*Nick Winter <nwinter@virginia.edu>

**RE: st: RE: graph command: xline() with by() option***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**Re: st: RE: graph command: xline() with by() option** - Next by Date:
**Re: st: Multicollinearity and Orthogonalization** - Previous by thread:
**RE: st: RE: graph command: xline() with by() option** - Next by thread:
**st: Different p-values in same model (comparing mim and estimates tab)** - Index(es):

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