perm.relation: Permutation Test for a Relationship

Description Usage Arguments Details Value Author(s) Examples

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

1
2
3
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# 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.

Example output

'data.frame':	10 obs. of  2 variables:
 $ DISTANCE: num  50 175 270 375 425 580 710 790 890 980
 $ PRICE   : num  1.8 1.2 2 1 1 1.2 0.8 0.6 1 0.85


 RESULTS OF PERMUTATION RELATIONSHIP TEST
 BASED ON 9999 REPLICATIONS 

    SUMMARY Variable.1 Variable.2  n   Statistic   Observed
 STATISTICS      PRICE   DISTANCE 10 pearson.cor -0.7271081

 HYPOTHESIS        Null  Alternative P.value
       TEST no.relation neg.relation  0.0069




 RESULTS OF PERMUTATION RELATIONSHIP TEST
 BASED ON 9999 REPLICATIONS 

    SUMMARY Variable.1 Variable.2  n   Statistic   Observed
 STATISTICS      PRICE   DISTANCE 10 kendall.cor -0.5820252

 HYPOTHESIS        Null  Alternative P.value
       TEST no.relation neg.relation  0.0118




 RESULTS OF PERMUTATION RELATIONSHIP TEST
 BASED ON 9999 REPLICATIONS 

    SUMMARY Variable.1 Variable.2  n    Statistic   Observed
 STATISTICS      PRICE   DISTANCE 10 spearman.cor -0.7570127

 HYPOTHESIS        Null  Alternative P.value
       TEST no.relation neg.relation  0.0075

wPerm documentation built on May 2, 2019, 3:02 a.m.