Statalist The Stata Listserver


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

st: Output table for mkcorr


From   Richard Lo <[email protected]>
To   [email protected]
Subject   st: Output table for mkcorr
Date   Sun, 1 Apr 2007 14:42:56 +0100 (BST)

Dear All,

Someone asked how to specify multiple significance levels (at 1, 5 ,10) for the pairwise Pearson
correlations with the output like the following table.

        Var 1	   Var2	      Var3
var 1	1.00

Var 2   0.16 **    1.00

Var 3   0.55 ***   0.10 *     1.00

A reply message suggests to modify pwcorr.ado (See
http://www.stata.com/statalist/archive/2006-07/msg00686.html (Re: st: star option)). As I am no
expert in Stata programming, I found it difficult to modify it. However I think I have a chance in
the user defined command mkcorr. I made some modifications but the results I got is a message
"invalid syntax".  

Could anyone advise the mistakes that I have made.  

Thank you for your kind advice in advance.

Richard Lo


**************** Part of the program in command mkcorr" to print p-value
***************
if "`sig'"~="" {
file write `output' _tab
if "`means'"~="" {
file write `output' _tab(4)
}
if "`num'"~="" {
file write `output' _tab
}
forvalues col=1/`row' {
local var1:word `row' of `varlist'
local var2:word `col' of `varlist'
if "`row'"=="`col'" {
file write `output' "" _tab
}
else {
qui correlate `var1' `var2' `if' `in'
local rho=`r(rho)'
local n=`r(N)'
local p=min(tprob(r(N)-2,r(rho)*sqrt(r(N)-2)/sqrt(1-r(rho)^2)),1)
file write `output' "(" `cformat' (`p') ")" _tab
}
}
file write `output' _n
}
}
*******************

What I have done:
****************
1. add a line
local sformat "%5s"

2 add the following lines after "local
p=min(tprob(r(N)-2,r(rho)*sqrt(r(N)-2)/sqrt(1-r(rho)^2)),1)"
with changes made in "file write `output' "(" `cformat' (`p') ")" _tab ".

				
if `p'<=0.01 { 
local star "***" 
}
else if `p'<=0.05 {
local star "**" 
}
else if `p'<=0.10 {
local star "*" 
}
else  {
local star "  " 
}
file write `output' "(" `sformat' (`star') ")" _tab
}
                            
*******************



	
	
		
___________________________________________________________ 
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the Yahoo! Mail Championships. Plus: play games and win prizes. 
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk 
*
*   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