perm.ind.loc: Independent-Samples Permutation Test for Difference in...

Description Usage Arguments Details Value Note Author(s) Examples

Description

Performs a permutation (randomization) test for difference in location based on independent samples from two populations.

Usage

1
2
3
perm.ind.loc(x, y, parameter, stacked = TRUE, variable = NULL,
             alternative = c("two.sided", "less", "greater"),
             R = 9999)

Arguments

x

a numeric vector of observations of the variable (stacked case) or a numeric vector of data values representing the first of the two samples (unstacked case).

y

a vector of corresponding population identifiers (stacked case) or a numeric vector of data values representing the second of the two samples (unstacked case).

parameter

the location parameter under consideration (e.g., mean, trimmed mean).

stacked

a logical value (default TRUE) indicating whether the data are stacked.

variable

an optional character string that gives the name of the variable under consideration; ignored if stacked is TRUE.

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 the distributions of the variable on the two populations are identical—"identical".

The possible alternative hypotheses are:

Two tailed ("two.sided"): The distribution of the variable on the first population has either systematically smaller values or systematically larger values than that of the variable on the second population—"shifted".

Left tailed ("less"): The distribution of the variable on the first population has systematically smaller values than that of the variable on the second population—"shifted.left".

Right tailed ("greater"): The distribution of the variable on the first population has systematically larger values than that of the variable on the second population—"shifted.right".

Value

A list with class "perm.ts.ind" containing the following components:

Stacked

TRUE if the data are stacked, FALSE otherwise.

Perm.values

the values of the test statistic obtained from the permutations.

Header

the main title for the output.

Variable

the name of the variable under consideration or NULL.

Pop.1

the first population.

Pop.2

the second population.

n.1

the sample size for the first population.

n.2

the sample size for the second population.

Statistic

the test statistic.

Observed

the observed value of the test statistic.

Null

the null hypothesis; here, always identical.

Alternative

the alternative hypothesis.

P.value

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

p.value

the P-value.

Note

For the permutation test, we need to assume that, under the null hypothesis, the two distributions are identical (i.e., the variable under consideration has the same distribution on both populations). If the two distributions have the same shape and spread, then a null hypothesis of equal population means or equal population medians implies that the two distributions are identical.

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
# Annual salaries, in thousands of dollars, for independent samples of
# faculty in private and public institutions.
data("salary")
str(salary)
attach(salary)
# Note that the data are stacked.

# Independent-samples permutation test to decide whether there is a
# difference in location for salaries of faculty in private and public
# institutions, using the mean as the location parameter.
perm.ind.loc(SALARY, TYPE, mean)

# Independent-samples permutation test to decide whether faculty in private
# institutions have systematically larger salaries than those in public
# institutions, using the 20% trimmed mean as the location parameter.
tr20.mean <- function(x) mean(x, trim = 0.20)
perm.ind.loc(SALARY, TYPE, tr20.mean, alternative = "greater")

detach(salary)  # clean up.

Example output

'data.frame':	65 obs. of  2 variables:
 $ TYPE  : Factor w/ 2 levels "PRIVATE","PUBLIC": 1 1 1 1 1 1 1 1 1 1 ...
 $ SALARY: num  97.3 85.9 118.8 93.9 66.6 ...


 RESULTS OF PERMUTATION INDEPENDENT TWO-SAMPLE LOCATION TEST
 BASED ON 9999 REPLICATIONS 

    SUMMARY Variable   Pop.1  Pop.2 n.1 n.2 Statistic Observed
 STATISTICS   SALARY PRIVATE PUBLIC  35  30 diff.mean 15.01429

 HYPOTHESIS      Null Alternative P.value
       TEST identical     shifted  0.0192




 RESULTS OF PERMUTATION INDEPENDENT TWO-SAMPLE LOCATION TEST
 BASED ON 9999 REPLICATIONS 

    SUMMARY Variable   Pop.1  Pop.2 n.1 n.2      Statistic Observed
 STATISTICS   SALARY PRIVATE PUBLIC  35  30 diff.tr20.mean 15.45238

 HYPOTHESIS      Null   Alternative P.value
       TEST identical shifted.right  0.0202

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