Last data update: 2014.03.03

R: Compute Pearson or Spearman Correlations with p-Values
rcorr.adjustR Documentation

Compute Pearson or Spearman Correlations with p-Values

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

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

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

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(RcmdrMisc)
Loading required package: car
Loading required package: sandwich
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RcmdrMisc/rcorr.adjust.Rd_%03d_medium.png", width=480, height=480)
> ### Name: rcorr.adjust
> ### Title: Compute Pearson or Spearman Correlations with p-Values
> ### Aliases: rcorr.adjust print.rcorr.adjust
> ### Keywords: htest
> 
> ### ** Examples
> 
> if (require(car)){
+     data(Mroz)
+     rcorr.adjust(Mroz[,c("k5", "k618", "age", "lwg", "inc")])
+     rcorr.adjust(Mroz[,c("k5", "k618", "age", "lwg", "inc")], type="spearman")
+     }

 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       
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>