The main function for univariate and multivariate testing under a
permutation (and rotation) framework + some utilities.
flip
is the main function for permutation (or rotation) test.
It allows for multivariate one sample, C>=2 samples and any regression
tests. Also the use of covariates (to be fitted in the model but) not under
test is allowed.
statTest="t"
is the t statistic derived from the correlation among
each Xs and each Ys (i.e. a linear model for each couples of Xs and Ys).
This is different from the fit of a multiple (multivariate) linear models,
since the correlation does not consider the other covariates). The test
t
is valid only under the assumption that each variable in X is
independent of each variable in Y. To get adequate test while adjusting for
covariates, use Z
(see example below) The test statistic "sum"
is the sum of values (or frequencies) of the given sample centered on the
expected (i.e. computed on the overall sample). "coeff"
is the
statistic based on the estimated coefficient of an lm
. It produces a
test for every possible combination of (columns of) X
and Y
(p-values can be combined using npc
). "cor"
is the correlation
(i.e. not partial correlation) between each column of X
and each of
Y
. "cor.Spearman"
(or "cor.rank"
) is the analogous for
Spearman's rank correlation coefficient.
"ANOVA"
is synonyms of "F"
. Only valid for dependence tests
(i.e. non constant X
). "Mann-Whitney"
is synonyms of
"Wilcoxon"
. "rank"
choose among "Wilcoxon"
and
"Kruskal-Wallis"
depending if the samples are two or more
(respectively).
The "Wilcoxon"
statistic is based on the 'sum of ranks of second
sample minus n1*(n+1)/2' instead of 'sum of ranks of smallest sample minus
nSmallest*(n+1)/2'. Therefore the statistic is centered on 0 and allow for
two sided alternatives. Despite the p-value are ok, it requires the X
to be a two-levels factor in order to compute the right test statistic. When
the X
is not a two-levels factor, it measures the codeviance among
X
and ranks of Y
.
For paired samples (see also the argument Strata
and the example
below) the Signed Rank test is performed. To perform the Sign Test use
option Sign
(i.e. same as Signed Rank but without using magnitude of
ranks).
The "Fisher"
test is allowed only with dichotomous Y
s. The
reported statistic is the bottom-right cell of the 2 by 2 frequencies table.
The "chisq.separated"
test perform cell-wise chi squared (see also
Finos and Salmaso (2004) Communications in Statistics - Theory and methods).
The "McNemar"
test is based on the signs of the differences, hence it
can be used also with ordinal or continuous responses. Only valid for
symmetry tests (i.e. X
is constant or NULL
). The reported
statistic for "McNemar"
test is the signed squared root of the
McNemar statistic. Hence it allows for tailed alternatives.
For ordered X
, a stochastic ordering test can be performed using
"t","Wilcoxon","sum"
and then combining the separated test using
npc
.
When statTest
is a function
, the first argument must be
Y
. This same function is ran to observed data Y
and to a
number of permuted rows of Y
. The returned value must be a vector of
test statistics. Please note that argument tail
must be defined
accordingly. The default way the rows of Y
are rearranged is through
permutation (without strata). More complex permutation strategies can be
defined through proper definition of argument perm
(see also
permutationSpace
).
For testType="rotation"
: As long as the number of orthogonalized
residuals (i.e. the number of observations minus the number of columns in
Z
) is lower than 50, the function rom
is used. The the number
is larger, the faster version romFast
is used instead. Although the
latter is less accurate, for such a big sample size, it is not expected to
affect the control of the type I error.