perm.paired.loc: Paired-Sample Permutation Test for Difference in Location

Description Usage Arguments Details Value Author(s) Examples

Description

Performs a permutation (randomization) test for difference in location based on a paired sample.

Usage

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

Arguments

x

a numeric vector of data values representing the first components of the pairs.

y

a numeric vector of data values representing the second components of the pairs.

parameter

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

variable

an optional character string that gives the name of the variable under consideration.

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.paired.loc" containing the following components:

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

the sample size.

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.

Author(s)

Neil A. Weiss

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Ages of a sample of 10 heterosexual spouses.
data("spouse.ages")
str(spouse.ages)
attach(spouse.ages)

# Paired-sample permutation test to decide whether there is a difference
# in location for age distributions of married men and married women,
# using the mean as the location parameter. Variable named "Age".
perm.paired.loc(HUSBAND, WIFE, mean, "Age")

# Paired-sample permutation test to decide whether married men have
# systematically greater ages than married women, using the 10% trimmed
# mean as the location parameter.
tr10.mean <- function(x) mean(x, trim = 0.10)
perm.paired.loc(HUSBAND, WIFE, tr10.mean, alternative = "greater")

detach(spouse.ages)  # clean up.

Example output

'data.frame':	10 obs. of  2 variables:
 $ HUSBAND: int  59 21 33 78 70 33 68 32 54 52
 $ WIFE   : int  53 22 36 74 64 35 67 28 41 44


 RESULTS OF PERMUTATION PAIRED LOCATION TEST
 BASED ON 9999 REPLICATIONS 

    SUMMARY Variable   Pop.1 Pop.2  n Statistic Observed
 STATISTICS      Age HUSBAND  WIFE 10 diff.mean      3.6

 HYPOTHESIS      Null Alternative P.value
       TEST identical     shifted  0.0528




 RESULTS OF PERMUTATION PAIRED LOCATION TEST
 BASED ON 9999 REPLICATIONS 

    SUMMARY   Pop.1 Pop.2  n      Statistic Observed
 STATISTICS HUSBAND  WIFE 10 diff.tr10.mean    4.125

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

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