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

From |
"Michael S. Hanson" <mshanson@wesleyan.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: Compact list of correlation, by cross-section |

Date |
Tue, 3 Aug 2004 15:39:09 -0400 |

On Aug 3, 2004, at 12:53 PM, Nick Cox wrote:

Unfortunately, omitting the second "if" condition does not produce what I am looking for: since there are t observations for each id, t > count(id) = 50, the first id is shown 50 times along with the (otherwise correct) correlation coefficients. Given the solutions below, I'm not going to spend more time on this now....The condition "if idn == `i'" is not only illegal, but in any case irrelevant to the -display-. It should just be omitted. That is, the -correlate- command already took care of the restriction you want, and there is only one correlation available to display, so no ambiguity.

This does work, although the way -tabdisp- handles missing values initially had me confused. One of the series is missing observations at the beginning of the (time series) sample, so the initial values of "corr" where missing; -tabdisp- shows these values -- as blanks. Instead,As it happens, there are other solutions. Here are two: * The -egenmore- package on SSC includes a -corr()- function, so that I think you need something like egen corr = corr(x y), by(id) tabdisp id, c(corr)

tabdisp id if ~missing(corr), c(corr)

did the trick.

Thanks, this works quite nicely! (I can always use the "saving" option and then re-use my prior datafile.)* -statsby- offers an even simpler solution, but you lose your data. That may or may not be what you want. statsby "corr x y" corr=r(rho) , by(id)

Yes, it certainly does. Momentary brain freeze or something. Thanks again, Nick.Incidentally, -generate- accepts -if- conditions.

-- Mike

*

* 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: RE: Compact list of correlation, by cross-section***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: looping graph and changing title** - Next by Date:
**st: RE: looping graph and changing title** - Previous by thread:
**st: RE: Compact list of correlation, by cross-section** - Next by thread:
**RE: st: RE: Compact list of correlation, by cross-section** - Index(es):

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