Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: accumulating pwcorr output


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: accumulating pwcorr output
Date   Mon, 30 Jun 2003 21:24:14 +0100

Pijus Virketis

> I am calculating many pwcorr's in succession. Unfortunately, the
> standard tabular output has too much filler to be used directly for
> presentation of results, and I have been cutting the
> unneeded portions
> by hand in a text editor. It would be great to be able to
> capture only
> the needed output in a vector, and output only that:
> efficient to read
> onscreen, and good for presenting on paper. In pseudocode,
> it would go
> something like:
>
> matrix q = (1\2\3\4\5\6\7\8\9\10)
> matrix sig = (1\2\3\4\5\6\7\8\9\10)
>
> forvalues k = 1/10 {
> 	quietly pwcor x`k' y`k', sig
> 	matrix q[`k',1] = e(q)
> 	matrix sig[`k',1] = e(sig)
> }
>
> matrix list q
> matrix list sig
>
> Unfortunately, pwcorr appears to overwrite the useful xy
> covariance with
> yy covariance (1.00, naturally), and does not leave behind the
> significance value at all. Can something like what I sketch above be
> done, or do I have to build a succinct_pwcorr() function
> from the ground up?

You need to write your own, but you've done part
already.

mat q = J(10,1,0)
mat sig = J(10,1,0)
qui forval k = 1/10 {
	corr x`k' y`k'
 	matrix q[`k',1] = r(rho)
 	matrix sig[`k',1] = min(tprob(r(N)-2, r(rho)*sqrt(r(N)-2)/
sqrt(1-r(rho)^2)),1)
}

The main extras over what you have:

1. Initialise matrices.
2. Forget -pwcorr-, drill down to -corr-.

Loosely similar problems are discussed in SJ 2(2), 202-222 (2002).
The gist is on-line at
http://www.stata.com/support/meeting/8uk/fortitude.pdf

Nick
[email protected]


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



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