Skip to contents

[Experimental]

Providing the confidence interval of Spearman's rank correlation by Bootstrap, and define the specific H0 as per your request, that is based on Fisher's Z transformation of the correlation but with the variance recommended by Bonett and Wright (2000), not the same as Pearson's.

Usage

spearmanTest(
  x,
  y,
  h0 = 0,
  conf.level = 0.95,
  alternative = c("two.sided", "less", "greater"),
  nrep = 1000,
  rng.seed = NULL,
  ...
)

Arguments

x

(numeric)
one measurement.

y

(numeric)
another measurement.

h0

(numeric)
a specified hypothesized value of the difference between the two correlations, default is 0.

conf.level

(numeric)
significance level for the returned confidence interval and hypothesis.

alternative

(string)
string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

nrep

(integer)
number of replicates for bootstrapping, default is 1000.

rng.seed

(integer)
number of the random number generator seed for bootstrap sampling. If set to NULL currently in the R session used RNG setting will be used.

...

other arguments to be passed to cor.test().

Value

a named vector contains correlation coefficient (cor), confidence interval(lowerci and upperci), Z statistic (Z) and p-value (pval)

References

NCSS correlation document

See also

cor.test() boot() to see the detailed arguments.

Examples

x <- c(44.4, 45.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1)
y <- c(2.6, 3.1, 2.5, 5.0, 3.6, 4.0, 5.2, 2.8, 3.8)
spearmanTest(x, y, h0 = 0.5, alternative = "greater")
#> $stat
#>        cor    lowerci    upperci          Z       pval 
#>  0.6000000 -0.1581140  0.9765538  0.3243526  0.3728355 
#> 
#> $method
#> [1] "Spearman's correlation"
#> 
#> $conf.level
#> [1] 0.95
#>