osTtestRandomSigns: Create random signs for one-sample and paired samples t-tests

Description Usage Arguments Value Examples

View source: R/ttest.R

Description

This function creates a random sample of -1L and 1L values which can be used in randomization runs of one-sample and paired samples t-tests. Care is taken so that all samples are unique.

Usage

1
osTtestRandomSigns(obj, nperm, seed)

Arguments

obj

a list object returned by preTtest; the number of rows (let's denote here 'id_length') of obj$.arraydat is relevant

nperm

integer indicating the number of permutations

seed

an integer value which specifies a seed (default: NULL), or a list of arguments passed to set.seed

Value

osTtestRandomSigns returns an integer matrix (containing only -1L and 1L values) with 'id_length' rows and 'nperm' columns.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
# this should fail: too many permutations for this sample size
obj <- list(.arraydat = matrix(8))
temp <- try(osTtestRandomSigns(obj, 1e4), silent = TRUE)
stopifnot(inherits(temp, "try-error"))

# expect an integer matrix containing unique series of -1L and 1L
obj <- list(.arraydat = matrix(10))
temp <- osTtestRandomSigns(obj, 500)
stopifnot(range(temp), c(-1L, 1L))
stopifnot(length(unique(as.vector(temp))) == 2L)
stopifnot(!anyDuplicated(temp, MARGIN = 2L))

obj <- list(.arraydat = matrix(20))
temp <- osTtestRandomSigns(obj, 1e4)
stopifnot(!anyDuplicated(temp, MARGIN = 2L))

## End(Not run)

tdeenes/eegR documentation built on April 19, 2021, 4:17 p.m.