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

View source: R/spearmanCI.R

spearmanCIR Documentation

Jackknife Euclidean / Empirical Likelihood Inference for Spearman's Correlation

Description

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

Usage

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

logical; if TRUE, it plots 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

## 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 June 22, 2024, 9:15 a.m.