Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: Table of partial correlation coefficients
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
RE: st: Table of partial correlation coefficients
Date
Fri, 11 Mar 2011 16:58:50 +0000
That's nice. Here's the idea wrapped up in a program
* Richard Williams plus ghost writer 11 March 2011
program richard
version 8.2
syntax varlist(numeric) [if] [in]
marksample touse
tokenize "`varlist'"
local nvars : word count `varlist'
qui forval i = 1/`nvars' {
local vlist : list varlist - `i'
regress ``i'' `vlist' if `touse'
estadd pcorr
est store m`i'
local mlist `mlist' m`i'
}
esttab `mlist', main(pcorr) not noconstant nostar
drop _est_m*
end
. richard mpg trunk weight length price
-----------------------------------------------------------------------------
(1) (2) (3) (4) (5)
mpg trunk weight length price
-----------------------------------------------------------------------------
trunk -0.0240 -0.0797 0.363 0.0317
weight -0.202 -0.0797 0.830 0.409
length -0.174 0.363 0.830 -0.292
price -0.122 0.0317 0.409 -0.292
mpg -0.0240 -0.202 -0.174 -0.122
-----------------------------------------------------------------------------
N 74 74 74 74 74
-----------------------------------------------------------------------------
pcorr coefficients
Nick
[email protected]
Richard Williams
At 10:38 AM 3/11/2011, Charles Koss wrote:
>Richard, thank you for following up. Based on your code, I would like
>to summarize the results from pcorr. Let's say I run:
>
>webuse auto
>pcorr price mpg trunk weight length
>pcorr mpg price trunk weight length
>pcorr trunk price mpg weight length
>pcorr weight price mpg trunk length
>pcorr length price mpg trunk weight
>
>Then, I would like to make a summary of the results from the previous
>5 lines of code. I know I can copy & paste but imagine how easy would
>it be to obtain a table resembling the corr command output.
OK, so by one variable, you meant one dependent variable. How about
something like this? You'll need to get estadd and esttab from SSC first.
webuse auto, clear
reg price mpg trunk weight length
estadd pcorr
est store m1
reg mpg price trunk weight length
estadd pcorr
est store m2
reg trunk price mpg weight length
estadd pcorr
est store m3
reg weight price mpg trunk length
estadd pcorr
est store m4
reg length price mpg trunk weight
estadd pcorr
est store m5
esttab m1 m2 m3 m4 m5, main(pcorr) not noconstant nostar
The output from the last command is
. esttab m1 m2 m3 m4 m5, main(pcorr) not noconstant nostar
-----------------------------------------------------------------------------
(1) (2) (3) (4) (5)
price mpg trunk weight length
-----------------------------------------------------------------------------
mpg -0.122 -0.0240 -0.202 -0.174
trunk 0.0317 -0.0240 -0.0797 0.363
weight 0.409 -0.202 -0.0797 0.830
length -0.292 -0.174 0.363 0.830
price -0.122 0.0317 0.409 -0.292
-----------------------------------------------------------------------------
N 74 74 74 74 74
-----------------------------------------------------------------------------
pcorr coefficients
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/