Learn R Programming

RVAideMemoire (version 0.9-45-2)

pcor.test: Tests for (semi-)partial association/correlation between paired samples

Description

Test for (semi-)partial association between paired samples while controlling for other variables, using one of Pearson's product moment correlation coefficient or Spearman's rho.

Usage

pcor.test(x, y, z, semi = FALSE, conf.level = 0.95, nrep = 1000,
  method = c("pearson", "spearman"))

Arguments

x
a numeric vector.
y
a numeric vector.
z
a numeric vector, matrix, data frame or list giving the controlling variables. For matrices, variables must be placed in columns.
semi
logical. If TRUE the semi-partial correlation coefficient is computed and tested. In that case only y is controlled for z.
conf.level
confidence level for confidence interval..
nrep
number of replicates for computation of the confidence interval of a Spearman's rank correlation coefficient (by bootstraping).
method
a character string indicating which correlation coefficient is to be used for the test. One of "pearson" or "spearman".

Value

  • data.namea character string giving the name(s) of the data.
  • alternativea character string describing the alternative hypothesis, always two-sided.
  • methoda character string indicating how the association was measured.
  • conf.inta condidence interval for the measure of association.
  • statisticthe value of the test statistic.
  • parameterthe degrees of freedom of the test (only for a Pearson's correlation coefficient).
  • p.valuethe p-value of the test.
  • estimatethe estimated measure of association, with name "cor" or "rho" corresponding to the method employed.
  • null.valuehe value of the association measure under the null hypothesis, always 0.

Details

If method is "pearson" and if there are at least 4+k complete series of observation (where k is the number of controlling variables), an asymptotic confidence interval of the correlation coefficient is given based on Fisher's Z transform. If method is "spearman", the p-value is computed through the AS89 algorithm if the number of complete series of observation is less than 10, otherwise via the asymptotic t approximation (in both cases the pspearman function is used). A confidence interval of the correlation coefficient, computed by bootstraping, is given.

See Also

pcor

Examples

Run this code
set.seed(1444)
x <- 1:30
y <- 1:30+rnorm(30,0,2)
z1 <- runif(30,0,4)
z2 <- 30:1+rnorm(30,03)
pcor.test(x,y,z1)
pcor.test(x,y,list(z1,z2))

Run the code above in your browser using DataLab