| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Output table for mkcorr
If you compare the line
file write `output' "(" `sformat' (`star') ")" _tab
with the help for -write- I think you will see that it
does not match any legal syntax. You can't specify
a format with a string output. You need to do the formatting
away from that, e.g.
local star : di %5s `star'
file write `output' `star' _tab
That said, starring is deprecated by the undersigned.
It is a very prinitive procedure.
Nick
[email protected]
Richard Lo
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.
**************** 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
*
* 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/