[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: RE: Compact list of correlation, by cross-section
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.
As it happens, there are other solutions. Here
* 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
Incidentally, -generate- accepts -if- conditions.
* For searches and help try: