shuffleSet returns a set of
nset permutations from the
specified design. The main purpose of the function is to circumvent
the overhead of repeatedly calling
shuffle to generate a
set of permutations.
1 2 3 4
numeric; the number of observations in the sample set. May also be
any object that
numeric; the number of permutations to generate for the set. Can be
missing, the default, in which case
an object of class
logical; should the design be checked for various problems via
logical; should messages by suppressed?
an object of class
arguments passed to other methods. For the
shuffleSet is designed to generate a set of
permutation indices over which a function can iterate as part of a
permutation test. It is only slightly more efficient than calling
nset times, but it is far more practical
than the simpler function because a set of permutations can be worked
on by applying a function to the rows of the returned object. This
simplifies the function applied, and facilitates the use of parallel
processing functions, thus enabling a larger number of permutations to
be evaluated in reasonable time.
shuffleSet will check the permutations design
following a few simple heuristics. See
check for details
of these. Whether some of the heuristics are activiated or not can be
how, essentialy via its argument
minperm. In particular, if there are fewer than
shuffleSet will generate and return all
possible permutations, which may differ from the number requested via
check argument to
shuffleSet controls whether
checking is performed in the permutation design. If you set
check = FALSE then exactly
nset permutations will be
returned. However, do be aware that there is no guarantee that the set
of permutations returned will be unique, especially so for designs and
data sets where there are few possible permutations relative to the
as.matrix method sets the
NULL and removes the
class, resulting in a standard matrix object.
Returns a matrix of permutations, where each row is a separate
permutation. As such, the returned matrix has
nset rows and
Gavin L. Simpson
shuffleSet() is modelled after the permutation schemes of Canoco
3.1 (ter Braak, 1990); see also Besag & Clifford (1989).
Besag, J. and Clifford, P. (1989) Generalized Monte Carlo significance tests. Biometrika 76; 633–642.
ter Braak, C. J. F. (1990). Update notes: CANOCO version 3.1. Wageningen: Agricultural Mathematics Group. (UR).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
set.seed(1) ## simple random permutations, 5 permutations in set shuffleSet(n = 10, nset = 5) ## series random permutations, 5 permutations in set shuffleSet(10, 5, how(within = Within(type = "series"))) ## series random permutations, 10 permutations in set, ## with possible mirroring CTRL <- how(within = Within(type = "series", mirror = TRUE)) shuffleSet(10, 10, CTRL) ## Permuting strata ## 4 groups of 5 observations CTRL <- how(within = Within(type = "none"), plots = Plots(strata = gl(4,5), type = "free")) shuffleSet(20, 10, control = CTRL) ## 10 random permutations in presence of Plot-level strata plotStrata <- Plots(strata = gl(4,5)) CTRL <- how(plots = plotStrata, within = Within(type = "free")) numPerms(20, control = CTRL) shuffleSet(20, 10, control = CTRL) ## as above but same random permutation within Plot-level strata CTRL <- how(plots = plotStrata, within = Within(type = "free", constant = TRUE)) numPerms(20, control = CTRL) shuffleSet(20, 10, CTRL) ## check this. ## time series within each level of Plot strata CTRL <- how(plots = plotStrata, within = Within(type = "series")) shuffleSet(20, 10, CTRL) ## as above, but with same permutation for each Plot-level stratum CTRL <- how(plots = plotStrata, within = Within(type = "series", constant = TRUE)) shuffleSet(20, 10, CTRL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.