ptest {AcrossTic}R Documentation

Permutation test for AcrossTic objects

Description

This function permutes the "y" entries in an AcrossTic object and computes the cross-count statistic for each permutation. This generates a null distribution suitable for use in a permutation test.

Usage

ptest(acobj, y, edge.weights, n = 1000)

Arguments

acobj

Object of class AcrossTic, output from rRegMatch.

y

Character, factor or logical indicating class membership for each observation. Normally this will be found inside acobj.

edge.weights

Vector of weights associated with each match. If omitted, the default is a vector of 1's of the proper length, unless the "acobj" object was computed with partial matching, in which case omitting edge.weights produces an error.

n

Integer, number of simulations. Default, 1000.

Details

This function permutes the y's n times and computes the cross-count-match statistic. If the observed value in the acobj is generally smaller than the permuted values, we conclude the distributions of the classes are different.

Value

A list with class AcrossTicPtest and three components:

sims

Vector of n cross-count values computed under permutation

observed

Observed cross-count statistic

p.value

P-value for test

Author(s)

Sam Buttrey and Dave Ruth

See Also

rRegMatch

Examples

set.seed (123)
X <- matrix (rnorm (100), 50, 2) # Create data...
y <- rep (c ("One", "Two"), each=25) # ...and class membership
## Not run: ptest (rRegMatch (X, r = 3, y = y)) # p = .479
X[1:25,] <- X[1:25,] + 1
## Not run: ptest (rRegMatch (X, r = 3, y = y)) # p = .037

[Package AcrossTic version 1.0-3 Index]