Description Usage Arguments Details Value Author(s) Examples
Performs a permutation (randomization) test for independence of two variables, using chi-square as the test statistic.
1 2 | perm.ind.test(x, type = c("cont", "flat", "raw"),
var.names = NULL, R = 9999)
|
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). |
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.
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. |
Neil A. Weiss
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # 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)
|
'data.frame': 12 obs. of 3 variables:
$ RELIGIOUSITY: Factor w/ 4 levels "Religious","Not religious",..: 1 2 3 4 1 2 3 4 1 2 ...
$ EDUCATION : Factor w/ 3 levels "Basic","Secondary",..: 1 1 1 1 2 2 2 2 3 3 ...
$ COUNT : int 77 23 8 6 149 56 24 15 78 36 ...
RELIGIOUSITY EDUCATION COUNT
1 Religious Basic 77
2 Not religious Basic 23
3 Atheist Basic 8
4 Don't know Basic 6
5 Religious Secondary 149
6 Not religious Secondary 56
7 Atheist Secondary 24
8 Don't know Secondary 15
9 Religious Advanced 78
10 Not religious Advanced 36
11 Atheist Advanced 29
12 Don't know Advanced 8
RESULTS OF PERMUTATION INDEPENDENCE TEST
BASED ON 999 REPLICATIONS
SUMMARY Variable.1 Variable.2 n Statistic Observed
STATISTICS Religiosity Education 509 chi.square 13.32231
HYPOTHESIS Null Alternative P.value
TEST nonassociated associated 0.04
'data.frame': 2 obs. of 4 variables:
$ SOCIAL_CLASS: Factor w/ 2 levels "Middle","Working": 1 2
$ A_few : int 4 5
$ Some : int 13 11
$ Lots : int 15 18
SOCIAL_CLASS A_few Some Lots
1 Middle 4 13 15
2 Working 5 11 18
RESULTS OF PERMUTATION INDEPENDENCE TEST
BASED ON 999 REPLICATIONS
SUMMARY Variable.1 Variable.2 n Statistic Observed
STATISTICS Social class Nursery-rhyme knowledge 66 chi.square 0.4903493
HYPOTHESIS Null Alternative P.value
TEST nonassociated associated 0.802
RESULTS OF PERMUTATION INDEPENDENCE TEST
BASED ON 999 REPLICATIONS
SUMMARY Variable.1 Variable.2 n Statistic Observed
STATISTICS Social class Nursery-rhyme knowledge 66 chi.square 0.4903493
HYPOTHESIS Null Alternative P.value
TEST nonassociated associated 0.779
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.