Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Maarten Buis <maartenlbuis@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: difference b/w corr and pwcorr |

Date |
Wed, 10 Apr 2013 10:59:17 +0200 |

On Wed, Apr 10, 2013 at 7:13 AM, Wu Zhang <wuzhang50@yahoo.com> wrote: --- On Apr 9, 2013, at 2:56 PM, Wu Zhang wrote: >> I wanna know the difference between correlation and pairwise correlation: very confusing, for some varlist, they are the same; while different for other varlist. The differ with respect to the way they deal with missing values. To compute a correlation you just need two variables, so if you ask for a matrix of correlations you could just do so by looking at each pair of variables separately and inlcude all observations that contain valid values for that pair. Alternatively, you could say that the entire list of variables defines your sample, in that case would first remove all observations that contain a missing value on any of the variables in the list of variables. -pwcorr- does the former and -corr- does the latter. In the example below, the variable rep78 is the only variable with missing values. So -corr- will compute the correlation between price and trunk on only those observations with valid values on rep78 price and trunk, while -pwcorr- will compute the correlation between price and trunk on those observations with valid values on price and trunk. You can use the -if- condition to let -pwcorr- behave like -corr-. *------------------ begin example ------------------ sysuse auto // only rep78 contains missing values corr rep78 price trunk pwcorr rep78 price trunk // reproduce the results from -corr- with -pwcorr-: pwcorr rep78 price trunk if !missing(rep78, price, trunk) *------------------- end example ------------------- (For more on examples I sent to the Statalist see: http://www.maartenbuis.nl/example_faq ) Hope this helps, Maarten --------------------------------- Maarten L. Buis WZB Reichpietschufer 50 10785 Berlin Germany http://www.maartenbuis.nl --------------------------------- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**st: difference b/w corr and pwcorr***From:*Wu Zhang <wuzhang50@yahoo.com>

**Re: st: difference b/w corr and pwcorr***From:*Alan Acock <acock@me.com>

**Re: st: difference b/w corr and pwcorr***From:*Wu Zhang <wuzhang50@yahoo.com>

- Prev by Date:
**st: 2013 German Stata Users Group Meeting -- Program** - Next by Date:
**st: New documentation for the runmlwin command Run MLwiN from within Stata** - Previous by thread:
**Re: st: difference b/w corr and pwcorr** - Next by thread:
**Re: st: difference b/w corr and pwcorr** - Index(es):