perm.relation {wPerm}R Documentation

Permutation Test for a Relationship

Description

Performs a permutation (randomization) test for a relationship (correlation, association) for two quantitative variables, using Pearson's r (product moment correlation coefficient), Spearman's rho (rank correlation coefficient), or Kendall's tau as the test statistic.

Usage

perm.relation(x, y, method = c("pearson", "kendall", "spearman"),
              alternative = c("two.sided", "less", "greater"),
              R = 9999)

Arguments

x

a numeric vector of data values representing the first variable.

y

a numeric vector of data values representing the second variable.

method

a character string indicating which method is to be used for the test; one of "pearson" (default), "kendall", or "spearman".

alternative

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

R

number of replications (default = 9999).

Details

The null hypothesis is that there is no relationship between the variables.

The possible alternative hypotheses are:

Two tailed ("two.sided"): There is a relationship between the variables—"relation".

Left tailed ("less"): There is a negative relationship between the variables—"neg.relation".

Right tailed ("greater"): There is a positive relationship between the variables—"pos.relation".

Value

A list with class "perm.two.var" containing the following components:

Perm.values

the values of the test statistic obtained from the permutations.

Header

the main title for the output.

Variable.1

the name of the first variable.

Variable.2

the name of the second variable.

n

the sample size.

Statistic

the test statistic.

Observed

the observed value of the test statistic.

Null

the null hypothesis; here, always no relation.

Alternative

the alternative hypothesis.

P.value

the P-value or a statement like P < 0.001.

p.value

the P-value.

Author(s)

Neil A. Weiss

Examples

# Prices, in euros, of a 50cl bottle of water and distances, in meters,
# of convenience stores from the Contemporary Art Museum in El Raval,
# Barcelona.
data("water")
str(water)
attach(water)

# Permutation test to decide whether a negative relationship exists
# between price and distance, using Pearson's r as the test statistic.
perm.relation(PRICE, DISTANCE, alternative = "less")

# Permutation test to decide whether a negative relationship exists
# between price and distance, using Kendall's tau as the test statistic.
perm.relation(PRICE, DISTANCE, "kendall", "less")

# Permutation test to decide whether a negative relationship exists
# between price and distance, using Spearman's rho as the test statistic.
perm.relation(PRICE, DISTANCE, "spearman", "less")

detach(water)  # clean up.

[Package wPerm version 1.0.1 Index]