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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

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

Subject |
st: RE: How to plot the cells of tabi like -catplot-? |

Date |
Wed, 26 Nov 2003 13:36:05 -0000 |

One way to tackle this -- and I think the easiest -- is just to write a wrapper like this: program catploti version 8 preserve tabi `0' catplot bar row col [fw=pop] end and to call it like this catploti 15 8\ 3 47, col chi2 replace Note: the -replace- is essential. So there are three steps: 1. -preserve- the data. (A -restore- later is automatic.) 2. Call up -tabi- with whatever arguments were given. 3. Call up -catplot- with the variables produced by -replace-. The weakness of this design is how to pass options to -catplot-. That can be done, with more programming effort, or if you have favourite defaults you can just wire them into the wrapper. A percent option is a case in point. Or, to put it another way, you could write two or three wrappers with different behaviour. Nick n.j.cox@durham.ac.uk eva.poen@unisg.ch > > I am making quite heavy use of -catplot-, available on SSC, > recently. This > nice program by Nick Cox (Thank you, Nick, once again!) plots a > categorical variable, in frequencies or percents, on its > own or against another categorical variable. > > However, this of course only works when you have variables. > I would like > to do the same with the values I entered as arguments to tabi. > > Example: > > . tabi 15 8\ 3 47, col chi2 > > +-------------------+ > | Key | > |-------------------| > | frequency | > | column percentage | > +-------------------+ > > | col > row | 1 2 | Total > -----------+----------------------+---------- > 1 | 15 8 | 23 > | 83.33 14.55 | 31.51 > -----------+----------------------+---------- > 2 | 3 47 | 50 > | 16.67 85.45 | 68.49 > -----------+----------------------+---------- > Total | 18 55 | 73 > | 100.00 100.00 | 100.00 > > Pearson chi2(1) = 29.7361 Pr = 0.000 > > > Now I would like to have the plot output just the same as > -catplot-, > something like this: > > > | > | 85.5 > | 83.3 + > | + + > | + + > | + + > | + + > | + + > | + + > | + 16.7 + > | + + 14.6 + > | + + + + > | + + + + > | + + + + > |-------------------------------------------- > row=1 row=2 row=1 row=2 > > > col=1 col=2 > > > > The same with frequencies. > Any ideas on how to do this? I really want to avoid using > excel for this. * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: How to plot the cells of tabi like -catplot-?***From:*eva.poen@unisg.ch

- Prev by Date:
**st: RE: computing the inverse square root of a matrix** - Next by Date:
**st: (general statistics) symbol for independent random variables** - Previous by thread:
**st: How to plot the cells of tabi like -catplot-?** - Next by thread:
**st: non-linear least squares** - Index(es):

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