rcorr.adjust: Compute Pearson or Spearman Correlations with p-Values

Description Usage Arguments Value Author(s) See Also Examples

Description

This function uses the rcorr function in the Hmisc package to compute matrices of Pearson or Spearman correlations along with the pairwise p-values among the correlations. The p-values are corrected for multiple inference using Holm's method (see p.adjust). Observations are filtered for missing data, and only complete observations are used.

Usage

1
2
3
4
5
rcorr.adjust(x, type = c("pearson", "spearman"), 
	use=c("complete.obs", "pairwise.complete.obs"))

## S3 method for class 'rcorr.adjust'
print(x, ...)

Arguments

x

a numeric matrix or data frame, or an object of class "rcorr.adjust" to be printed.

type

"pearson" or "spearman", depending upon the type of correlations desired; the default is "pearson".

use

how to handle missing data: "complete.obs", the default, use only complete cases; "pairwise.complete.obs", use all cases with valid data for each pair.

...

not used.

Value

Returns an object of class "rcorr.adjust", which is normally just printed.

Author(s)

John Fox, adapting code from Robert A. Muenchen.

See Also

rcorr, p.adjust.

Examples

1
2
3
4
5
if (require(car)){
    data(Mroz)
    print(rcorr.adjust(Mroz[,c("k5", "k618", "age", "lwg", "inc")]))
    print(rcorr.adjust(Mroz[,c("k5", "k618", "age", "lwg", "inc")], type="spearman"))
    }

Example output

Loading required package: car
Loading required package: sandwich

 Pearson correlations:
          k5    k618     age     lwg    inc
k5    1.0000  0.0842 -0.4339 -0.0184 0.0382
k618  0.0842  1.0000 -0.3854 -0.1048 0.0248
age  -0.4339 -0.3854  1.0000  0.0123 0.0586
lwg  -0.0184 -0.1048  0.0123  1.0000 0.1232
inc   0.0382  0.0248  0.0586  0.1232 1.0000

 Number of observations: 753 

 Pairwise two-sided p-values:
     k5     k618   age    lwg    inc   
k5          0.0209 <.0001 0.6145 0.2951
k618 0.0209        <.0001 0.0040 0.4974
age  <.0001 <.0001        0.7367 0.1078
lwg  0.6145 0.0040 0.7367        0.0007
inc  0.2951 0.4974 0.1078 0.0007       

 Adjusted p-values (Holm's method)
     k5     k618   age    lwg    inc   
k5          0.1254 <.0001 1.0000 1.0000
k618 0.1254        <.0001 0.0278 1.0000
age  <.0001 <.0001        1.0000 0.5392
lwg  1.0000 0.0278 1.0000        0.0056
inc  1.0000 1.0000 0.5392 0.0056       

 Spearman correlations:
          k5    k618     age     lwg    inc
k5    1.0000  0.1284 -0.4597 -0.0478 0.0004
k618  0.1284  1.0000 -0.4153 -0.1178 0.0547
age  -0.4597 -0.4153  1.0000  0.0153 0.0777
lwg  -0.0478 -0.1178  0.0153  1.0000 0.1628
inc   0.0004  0.0547  0.0777  0.1628 1.0000

 Number of observations: 753 

 Pairwise two-sided p-values:
     k5     k618   age    lwg    inc   
k5          0.0004 <.0001 0.1903 0.9923
k618 0.0004        <.0001 0.0012 0.1340
age  <.0001 <.0001        0.6758 0.0330
lwg  0.1903 0.0012 0.6758        <.0001
inc  0.9923 0.1340 0.0330 <.0001       

 Adjusted p-values (Holm's method)
     k5     k618   age    lwg    inc   
k5          0.0029 <.0001 0.5709 1.0000
k618 0.0029        <.0001 0.0072 0.5361
age  <.0001 <.0001        1.0000 0.1648
lwg  0.5709 0.0072 1.0000        <.0001
inc  1.0000 0.5361 0.1648 <.0001       

RcmdrMisc documentation built on Aug. 13, 2020, 9:06 a.m.