Virata manual

pwcorr

The same correlation grid, but each pair uses every row it can.

What we have

  • the correlation matrix, each pair on the rows that have both values

Coming later

Nothing known to be missing.

How you write it

pwcorr varlist

Square brackets mean optional. A vertical bar means choose one.

What it does

Where correlate drops a row if anything is missing, pwcorr computes each pair on whatever rows have both values (pairwise deletion). You keep more data, at the cost of different cells resting on different people.

Which to prefer depends on why the values are missing. When in doubt, run both: if they disagree noticeably, the missing data is telling you something.

Try it

Every example below was run after sysuse vira.sample02, clear.

. pwcorr mpce age education
             |       mpce        age  education
-------------+---------------------------------
        mpce |     1.0000                      
         age |     0.0683     1.0000           
   education |     0.2803    -0.0329     1.0000
The same thing in pandas and in R

pandas

df[['mpce', 'age', 'education']].corr()  # pairwise

R

cor(df[, c("mpce", "age", "education")], use = "pairwise.complete.obs")

# This R was run in a real R (4.6.1) and gave the same numbers.

Nearby

summarize tabulate tabstat correlate ttest mean