perm.ind.test {wPerm}R Documentation

Permutation Independence Test

Description

Performs a permutation (randomization) test for independence of two variables, using chi-square as the test statistic.

Usage

perm.ind.test(x, type = c("cont", "flat", "raw"),
              var.names = NULL, R = 9999)

Arguments

x

a data frame (see details below).

type

a character string indicating the type of data frame; must be one of "cont" (default), "flat", or "raw".

var.names

an optional character string of length two that gives the names of the variables under consideration; if omitted Var.1 and Var.2 are used.

R

number of replications (default = 9999).

Details

The null hypothesis is that the two variables are not associated (i.e., are independent). The alternative hypothesis is that the two variables are associated (i.e., are dependent).

Types of data frames permitted:

cont: In this type of data frame, the first variable gives the possible values of one of the two variables under consideration. The remaining variables of the data frame give the observed frequencies.

flat: This type of data frame consists of three variables. The first two variables give the pairs of possible values of the two variables under consideration; the third variable of the data frame gives the frequencies of the pairs.

raw: This type of data frame consists of two variables, which give the raw data of the two variables under consideration.

Value

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

Perm.values

the values of chi-square obtained from the permutations.

Header

the main title for the output.

Variable.1

the name of the first variable or Var.1

Variable.2

the name of the second variable or Var.2

Statistic

the statistic used for the permutation test; here, always chi.square.

Observed

the value of the chi-square statistic for the observed data.

n

the sample size.

Null

the null hypothesis; here, always nonassociated.

Alternative

the alternative hypothesis; here, always associated.

P.value

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

p.value

the P-value.

Author(s)

Neil A. Weiss

Examples

# Religious belief vs education for a sample of 509 people.
data("relig.and.ed")
str(relig.and.ed)
relig.and.ed
# Note that relig.and.ed is in the form of a flat contingency table ("flat").

# Permutation independence test to decide whether an association exists
# between religiosity and education, using 999 replications.
perm.ind.test(relig.and.ed, "flat", c("Religiosity", "Education"), 999)

# Social class vs nursery-rhyme knowledge for a sample of 66 grade-school
# children.
data("learning")
str(learning)
learning
# Note that the learning data is in the form of a contingency table ("cont").

# Permutation independence test to decide whether an association exists
# between social class and nursery-rhyme knowledge, using 999 replications.
perm.ind.test(learning, "cont", c("Social class", "Nursery-rhyme knowledge"), 999)
# Or, equivalently, since "cont" is the default "type":
perm.ind.test(learning, var.names = c("Social class", "Nursery-rhyme knowledge"), R = 999)

[Package wPerm version 1.0.1 Index]