spearmanCI: Jackknife Euclidean / Empirical Likelihood Inference for...

Description Usage Arguments Author(s) References Examples

View source: R/spearmanCI.R

Description

Computes jackknife Euclidean / empirical likelihood confidence intervals for Spearman's correlation.

Usage

1
spearmanCI(x, y, level = 0.95, method = "Euclidean", plot = FALSE)

Arguments

x

vector with data.

y

vector with data.

level

the confidence level required.

method

This must be one of the strings "Euclidean" or "empirical"; see references below for details.

plot

plot log-likelihood ratio function?

Author(s)

Miguel de Carvalho

References

de Carvalho, M. and Marques, F. J. (2012). Jackknife Euclidean likelihood-based inference for Spearman's rho. North American Actuarial Journal, 16, 487–492.

Wang, R., and Peng, L. (2011). Jackknife Empirical likelihood intervals for Spearman’s rho. North American Actuarial Journal, 15, 475–486.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Real data example
data(fire)
attach(fire)
spearmanCI(building, contents)

## The intervals in de Carvalho and Marques (2012, Section 3.2)
## differ slightly as they are based on the estimate 
## spearman <- function(x, y) {
##  n <- length(x)
##  F <- ecdf(x); G <- ecdf(y)
##  return(12 / n * sum((F(x) - 1 / 2) * (G(y) - 1 / 2)))  
## }

## Simulated data example
library(MASS)
pearson <- .7
Sigma <- matrix(c(1, pearson, pearson, 1), 2, 2)
xy <- mvrnorm(n = 1000, rep(0, 2), Sigma)
spearmanCI(xy[, 1], xy[, 2])
abline(v = 6 / pi * asin(pearson / 2), col = "grey", lty = 3)

spearmanCI documentation built on May 2, 2019, 10:28 a.m.