Calculate pairwise correlations between group levels with corrections for multiple testing.

pairwise.cor.test(
  x,
  g,
  p.adjust.method = p.adjust.methods,
  method = c("pearson", "kendall", "spearman"),
  ...
)

Arguments

x

response vector.

g

grouping vector or factor.

p.adjust.method

method for adjusting p values (see p.adjust). Can be abbreviated.

method

string argument to set the method to compute the correlation. Possibilities are "pearson" (the default), "kendall", and "spearman"

...

additional arguments passed to cor.test.

Value

Object of class pairwise.htest

Details

Note that correlation tests require that the two vectors examined are of the same length. Thus, if the grouping defines groups of varying lengths then the specific correlation is not computed and a NA is returned instead. The adjusted p values are only based on the actual correlation that are computed. Extra arguments that are passed on to cor.test may or may not be sensible in this context.

Examples


attach(airquality)
Month <- factor(Month, labels = month.abb[5:9])
pairwise.cor.test(Ozone, Month)
#> Warning: Group sizes are not identical
#> Warning: Group sizes are not identical
#> Warning: Group sizes are not identical
#> Warning: Group sizes are not identical
#> Warning: Group sizes are not identical
#> Warning: Group sizes are not identical
#> 
#> 	Pairwise comparisons using Pearson's product-moment correlation 
#> 
#> data:  Ozone and Month 
#> 
#>     May  Jun  Jul  Aug
#> Jun -    -    -    -  
#> Jul 0.74 -    -    -  
#> Aug 0.48 -    0.20 -  
#> Sep -    0.79 -    -  
#> 
#> P value adjustment method: holm 
pairwise.cor.test(Ozone, Month, p.adj = "bonf")
#> Warning: Group sizes are not identical
#> Warning: Group sizes are not identical
#> Warning: Group sizes are not identical
#> Warning: Group sizes are not identical
#> Warning: Group sizes are not identical
#> Warning: Group sizes are not identical
#> 
#> 	Pairwise comparisons using Pearson's product-moment correlation 
#> 
#> data:  Ozone and Month 
#> 
#>     May  Jun  Jul  Aug
#> Jun -    -    -    -  
#> Jul 1.00 -    -    -  
#> Aug 0.63 -    0.20 -  
#> Sep -    1.00 -    -  
#> 
#> P value adjustment method: bonferroni 
detach()