permTest {CarletonStats}R Documentation

Permutation test

Description

Permutation test to test a hypothesis involving two samples.

Usage

permTest(x, ...)

## Default S3 method:
permTest(x, group, statistic = mean, B = 9999,
  alternative = "two.sided", plot.hist = TRUE,
  legend.loc = "topright", plot.qq = FALSE, ...)

## S3 method for class 'formula'
permTest(formula, data = parent.frame(), subset, ...)

Arguments

x

a numeric vector. If the function is the mean (fun = mean) and x is a binary numeric vector of 0's and 1's, then the test is between proportions.

...

further arguments to be passed to or from methods.

group

a factor variable with two levels. If group is a binary numeric vector, it will be coerced into a factor variable.

statistic

the statistic of interest.

B

the number of resamples (positive integer greater than 2).

alternative

the alternative hypothesis. Options are "two.sided", "less" or "greater".

plot.hist

a logical value. If TRUE, the permutation distribution of the statistic is plotted.

legend.loc

location of the legend for the histogram. Options are "topleft", "topright", "bottomleft" or "bottomright".

plot.qq

a logical value. If TRUE, then a normal quantile-quantile plot of the resampled test statistic is created.

formula

a formula of the form y ~ group where y is numeric and group is a factor variable.

data

a data frame with the variables in the formula.

subset

an optional expression specifying which observations to keep.

Details

Permutation test to see if a population parameter is the same for two populations. For instance, test H_0: μ_M = μ_F where μ denotes the population mean. The values of the numeric variable are randomly assigned to the two groups and the difference of the statistic for each group is calculated. The command will print the mean and standard error of the distribution of the test statistic as well as a P-value.

Observations with missing values are removed.

Value

Returns invisibly a vector of the replicates of the test statistic.

Methods (by class)

Author(s)

Laura Chihara

References

Tim Hesteberg's website: http://www.timhesterberg.net/bootstrap

Examples


permTest(states03$ViolentCrime, states03$DeathPenalty)

#using formula syntax
permTest(ViolentCrime ~ DeathPenalty, data = states03, alt = "less")


[Package CarletonStats version 2.0 Index]