Nonparametric statistical inference methods for a modern and robust analysis of longitudinal and multivariate data in factorial experiments are essential for research. While existing approaches that rely on specific distributional assumptions of the data (multivariate normality and/or equal covariance matrices) are implemented in statistical software packages, there is a need for user-friendly software that can be used for the analysis of data that do not fulfill the aforementioned assumptions and provide accurate
Nowadays, a large amount of measurements are taken per experimental unit or subject in many experimental studiesrequiring inferential methods from multivariate analysis in a unified way. Here we distinguish between two cases:
If the same quantity is measured under different treatment conditions or at different time points, a repeated measures (RM) design is present. Therein, observations are measured on the same scale and are combinable. This is also the case if the measuring instrument produces multiple responses, e.g., microarrays in bioinformatics.
If different quantities are measured on the same unit or subject, a multivariate analysis of variance (MANOVA) design is apparent. In such a situation, data is measured on different scales and not combinable (e.g., height and weight).
These two different definitions do not only lead to different questions of interest but also require different inference procedures as outlined below. In particular, the main difference between the two approaches is that in repeated measures designs comparisons between the response variables are meaningful. This means that also hypotheses regarding sub-plot or within subject factors (e.g., time) are of interest. On the other hand, MANOVA settings are usually designed to detect effects of the observed factors (and interactions thereof) on the multivariate outcome vectors, thus allowing in contrast to multiple univariate ANOVA analysesto evaluate the combined changes of the outcome variables with respect to the factor levels.
Despite their differences, MANOVA- and RM-type techniques share the same advantages over classical univariate endpoint-wiseANOVA-typeanalyses:
Focusing on metric data and mean-based procedures, MANOVA and RM models
are typically inferred by means of “classical” procedures such as Wilks’
Lambda, Lawley-Hotelling, Roy’s largest root
(Anderson 2001; Davis 2002; Johnson and Wichern 2007) or (generalized) linear mixed
models with generalized estimating equations. For the classical one-way
layout, these methods are implemented in R within the manova
function
in the stats package,
where one can choose between the options Pillai
, Wilks
,
Hotelling-Lawley
and Roy
. Nonparametric rank-based methods for null
hypotheses formulated in distribution functions are implemented within
the packages npmv for one-
and two-way MANOVA (Burchett et al. 2017) and
nparLD for several
repeated measures designs (Noguchi et al. 2012). In case of fixed block effects, the
GFD package (Friedrich et al. 2017b),
which implements a permutation Wald-type test in the univariate setting,
can also be used.
(Generalized) linear mixed models are implemented in the lm
and the
glm
function (package stats) for univariate data as well as in the
SCGLR package for
Generalized Linear Model estimation in the context of multivariate data
(Cornu et al. 2018). The Anova
and Manova
function in the
car package (Fox and Weisberg 2011) calculate
type-II and type-III analysis-of-variance tables for objects produced
by, e.g., lm
, glm
or manova
in the univariate and multivariate
context, respectively. In the MANOVA context, repeated measures designs
can be included as well.
Furthermore, the packages flip (Finos et al. 2018) and ffmanova (Langsrud and Mevik 2019) contain interesting permutation and rotation tests, which, however, require certain invariances resulting in model restrictions (see, e.g., the discussion in Huang et al. 2006; Chung and Romano 2013) .
Most of these procedures, however, rely on specific distributional
assumptions (such as multivariate normality) and/or specific covariance
or correlation structures (e.g., homogeneity between groups or, for RM,
compound symmetry; possibly implying equal correlation between
measurements) which may often not be justifiable in real data. In
particular, with decreasing sample sizes and increasing dimensions, such
presumptions are almost impossible to verify in practice and may lead to
inflated type-I-errors, cf.
(Vallejo et al. 2001; Lix and Keselman 2004; Vallejo Seco et al. 2007; Livacic-Rojas et al. 2010).
To this end, several alternative procedures have been developed that
tackle the above problems and have been compared in extensive simulation
studies, see amongst others Brunner (2001; Lix and Lloyd 2007; Gupta et al. 2008; Zhang 2011; Harrar and Bathke 2012; Konietschke et al. 2015; McFarquhar et al. 2016; Xiao and Zhang 2016; Friedrich et al. 2017a; Livacic-Rojas et al. 2017; Bathke et al. 2018; Friedrich and Pauly 2018)
and the references cited therein. Here, we focus on nonparametric
statistical methods that are valid in the multivariate Behrens-Fisher
situationequal covariance matrices across the groups are not assumedand
provide accurate inferential results in terms of
More precisely, we focus on nonparametric methods for testing main and interaction effects of fixed factors in repeated measures designs and multivariate data. In particular, general Wald-type test statistics (for MANOVA and RM), ANOVA-type statistics (for RM) and modified ANOVA-type tests (for MANOVA) are implemented in MANOVA.RM (Friedrich et al. 2019) because
To make the methods freely accessible we have provided the R package MANOVA.RM for routine statistical analyses. It is available from the R Archive at https://CRAN.R-project.org/package=MANOVA.RM
The main functions RM
(for RM designs) and MANOVA
(for MANOVA
designs) are developed in style of the well known ANOVA functions lm
or aov
. Its user-friendly application not only provides the MANOVA
function even allows for an easy calculation and confidence
ellipsoid plots for specified multivariate contrasts as described in
Friedrich and Pauly (2018).
Specifically, for testing multivariate main- and interaction effects in
one-, two- and higher-way MANOVA models, the MANOVA
function provides
In addition to multivariate group-wise effects, the RM
function also
allows to test hypotheses formulated across within subject factors. The
implemented test statistics are
The paper is organized as follows: In Section 2 the multivariate statistical model as well as the implemented inference procedures are described. The application of the R package MANOVA.RM is exemplified on several Repeated Measures and MANOVA Examples in Section 3. Finally, the paper closes with a discussion in Section 4.
Throughout the paper we use the subsequent notation from multivariate
linear models: For
For both the RM and the MANOVA design equipped with an arbitrary number
of fixed factors, we consider the general linear model given by
Within this framework, hypotheses for RM or MANOVA can be formulated by
means of an adequate contrast hypothesis matrix
Let
This procedure is not only applicable for MANOVA but also for RM designs
(Bathke et al. 2018). However, Friedrich et al. (2017a) proposed a more
favourable technique for Repeated Measurements. It is based on an at
first blush chaotic resampling method: Wild permutation of all pooled
components without taking group membership or possible dependencies into
account. Denoting the resulting permuted data set as
In addition to these WTS procedures two other statistics are considered
as well. For RM the well-established ANOVA-type statistic (ATS)
PROC Mixed
procedure. Although known to be rather conservative it has the advantage
(over the WTS) of being applicable in case of eventually singular
covariance matrices
Similar to the permuted WTS the ATS given in Equation (3) is
only applicable for RM since it is not invariant under scale
transformations (e.g., change of units) of the univariate components. To
nevertheless provide a robust method for MANOVA settings which is also
applicable in case of singular
All of the aforementioned procedures are applicable in various factorial designs in a unified way, i.e., when more than one factor may impact the response. The specific models and the hypotheses being tested will be discussed in the next section.
In order to provide a general overview of different statistical designs
and layouts that can be analyzed with MANOVA.RM we exemplify few
designs that occur frequently in practical applications and discuss the
model, hypotheses and limitations. All of the methods implemented in
MANOVA.RM are even applicable in higher-way layouts than being
presented here; and the list should not be seen as the limited
application of the package. The models are derived by sub-indexing the
index
One-Way (
Crossed Two-Way (
Hierarchically nested Two-Way
(
Repeated Measures and Split Plot Designs are covered by setting
$$
with
parallel flat identical
Note, that we could also employ more complex factorial structures on
the repeated measurements (i.e., more within subject factors) by
splitting up the index
To demonstrate the use of the RM
and the MANOVA
function, we provide
several examples for both repeated measures designs and multivariate
data in the following. Furthermore, the MANOVA.RM package is equipped
with an optional GUI (graphical user interface), based on
RGtk2 (Lawrence and Temple Lang 2010), which will
be explained in detail in Section 3.3 below.
Both functions are structured similarly: The main input parameters are
the formula
specifying the outcome on the left hand side and the
factor variables of interest on the right, the data
and the
resampling
approach. The latter varies according to the design: the
user can choose between a parametric and a wild bootstrap and in the RM
design, additionally a permutation approach for the WTS is implemented.
The function RM
is built as follows:
R> RM(formula, data, subject, no.subf = 1, iter = 10000, alpha = 0.05,
+ resampling = "Perm", CPU, seed, CI.method = "t-quantile", dec = 3)
Data need to be provided in long format, i.e., one row per measurement.
Here, subject
specifies the column name of the subjects variable in
the data frame, while no.subf
denotes the number of within subject
factors considered. Note that in a setting with more than one between
subjects factor, the subject ids in the different groups need to be
different. Otherwise the program will erroneously assume that these
measurements belong to the same subject. The number of cores used for
parallel computing as well as a random seed can optionally be specified
using CPU
and seed
, respectively. For calculating the confidence
intervals, the user can choose between dec
digits.
The function RM
returns an object of class "RM"
from which the user
may obtain plots and summaries of the results using plot()
, print()
and summary()
, respectively. Here, print()
returns a short summary
of the results, i.e., the values of the test statistics along with
degrees of freedom and corresponding summary()
also
displays some descriptive statistics such as the means, sample sizes and
confidence intervals for the different factor level combinations.
Plotting is based on
plotrix (Lemon 2006). For
two- and higher-way layouts, the factors for plotting can be
additionally specified in the plot
call, see the examples below.
For illustration purposes, we consider the data set o2cons
, which is
included in MANOVA.RM. This data set contains measurements of the
oxygen consumption of leukocytes in the presence and absence of
inactivated staphylococci at three consecutive time points. Due to the
study design, both time and staphylococci are within subject factors
while the treatment (Verum vs. Placebo) is a between subject factor (see Friedrich et al. 2017a for more details).
R> data("o2cons")
R> model1 <- RM(O2 ~ Group * Staphylococci * Time, data = o2cons,
+ subject = "Subject", no.subf = 2, iter = 1000,
+ resampling = "Perm", seed = 1234)
R> summary(model1)
Call:
O2 ~ Group * Staphylococci * Time
A repeated measures analysis with 2 within-subject and 1 between-subject factors.
Descriptive:
Group Staphylococci Time n Means Lower 95 % CI Upper 95 % CI
1 P 0 6 12 1.322 1.150 1.493
5 P 0 12 12 2.430 2.196 2.664
9 P 0 18 12 3.425 3.123 3.727
3 P 1 6 12 1.618 1.479 1.758
7 P 1 12 12 2.434 2.164 2.704
11 P 1 18 12 3.527 3.273 3.781
2 V 0 6 12 1.394 1.201 1.588
6 V 0 12 12 2.570 2.355 2.785
10 V 0 18 12 3.677 3.374 3.979
4 V 1 6 12 1.656 1.471 1.840
8 V 1 12 12 2.799 2.500 3.098
12 V 1 18 12 4.029 3.802 4.257
Wald-Type Statistic (WTS):
Test statistic df p-value
Group "11.167" "1" "0.001"
Staphylococci "20.401" "1" "<0.001"
Group:Staphylococci "2.554" "1" "0.11"
Time "4113.057" "2" "<0.001"
Group:Time "24.105" "2" "<0.001"
Staphylococci:Time "4.334" "2" "0.115"
Group:Staphylococci:Time "4.303" "2" "0.116"
ANOVA-Type Statistic (ATS):
Test statistic df1 df2 p-value
Group "11.167" "1" "316.278" "0.001"
Staphylococci "20.401" "1" "Inf" "<0.001"
Group:Staphylococci "2.554" "1" "Inf" "0.11"
Time "960.208" "1.524" "Inf" "<0.001"
Group:Time "5.393" "1.524" "Inf" "0.009"
Staphylococci:Time "2.366" "1.983" "Inf" "0.094"
Group:Staphylococci:Time "2.147" "1.983" "Inf" "0.117"
p-values resampling:
Perm (WTS)
Group "0.005"
Staphylococci "0.001"
Group:Staphylococci "0.145"
Time "<0.001"
Group:Time "<0.001"
Staphylococci:Time "0.144"
Group:Staphylococci:Time "0.139"
The output consists of four parts: model1$Descriptive
gives an
overview of the descriptive statistics: The number of observations, mean
and confidence intervals are displayed for each factor level
combination. Second, model1$WTS
contains the results for the Wald-type
test: The test statistic, degree of freedom and model1$ATS
. This test
statistic tends to rather conservative decisions in case of small sample
sizes and is even asymptotically only an approximation, thus not
providing an asymptotic level model1$resampling
contains the
In this example, we find significant effects of all factors as well as a significant interaction between group and time.
We consider the data set EEG
from the MANOVA.RM package: At the
Department of Neurology, University Clinic of Salzburg, 160 patients
were diagnosed with either Alzheimer’s Disease (AD), mild cognitive
impairment (MCI), or subjective cognitive complaints without clinically
significant deficits (SCC), based on neuropsychological diagnostics
(Bathke et al. 2018). This data set contains
Note that due to the small number of subjects in some groups (e.g., only
2 male patients aged
R> data("EEG")
R> EEG_model <- RM(resp ~ sex * diagnosis * feature * region, data = EEG,
+ subject = "id", no.subf = 2, resampling = "WildBS",
+ iter = 1000, alpha = 0.01, CPU = 4, seed = 123)
R> summary(EEG_model)
Call:
resp ~ sex * diagnosis * feature * region
A repeated measures analysis with 2 within-subject and 2 between-subject factors.
Descriptive:
sex diagnosis feature region n Means Lower 99 % CI Upper 99 % CI
1 M AD brainrate central 12 -1.010 -4.881 2.861
13 M AD brainrate frontal 12 -1.007 -4.991 2.977
25 M AD brainrate temporal 12 -0.987 -4.493 2.519
7 M AD complexity central 12 -1.488 -10.053 7.077
19 M AD complexity frontal 12 -1.086 -6.906 4.735
31 M AD complexity temporal 12 -1.320 -7.203 4.562
3 M MCI brainrate central 27 -0.447 -1.591 0.696
15 M MCI brainrate frontal 27 -0.464 -1.646 0.719
27 M MCI brainrate temporal 27 -0.506 -1.584 0.572
9 M MCI complexity central 27 -0.257 -1.139 0.625
21 M MCI complexity frontal 27 -0.459 -1.997 1.079
33 M MCI complexity temporal 27 -0.490 -1.796 0.816
5 M SCC brainrate central 20 0.459 -0.414 1.332
17 M SCC brainrate frontal 20 0.243 -0.670 1.156
29 M SCC brainrate temporal 20 0.409 -1.210 2.028
11 M SCC complexity central 20 0.349 -0.070 0.767
23 M SCC complexity frontal 20 0.095 -1.037 1.227
35 M SCC complexity temporal 20 0.314 -0.598 1.226
2 W AD brainrate central 24 -0.294 -1.978 1.391
14 W AD brainrate frontal 24 -0.159 -1.813 1.495
26 W AD brainrate temporal 24 -0.285 -1.776 1.206
8 W AD complexity central 24 -0.128 -1.372 1.116
20 W AD complexity frontal 24 0.026 -1.212 1.264
32 W AD complexity temporal 24 -0.194 -1.670 1.283
4 W MCI brainrate central 30 -0.106 -1.076 0.863
16 W MCI brainrate frontal 30 -0.074 -1.032 0.885
28 W MCI brainrate temporal 30 -0.069 -1.064 0.925
10 W MCI complexity central 30 0.094 -0.464 0.652
22 W MCI complexity frontal 30 0.131 -0.768 1.031
34 W MCI complexity temporal 30 0.121 -0.652 0.895
6 W SCC brainrate central 47 0.537 -0.049 1.124
18 W SCC brainrate frontal 47 0.548 -0.062 1.159
30 W SCC brainrate temporal 47 0.559 -0.015 1.133
12 W SCC complexity central 47 0.384 0.110 0.659
24 W SCC complexity frontal 47 0.403 -0.038 0.845
36 W SCC complexity temporal 47 0.506 0.132 0.880
Wald-Type Statistic (WTS):
Test statistic df p-value
sex "9.973" "1" "0.002"
diagnosis "42.383" "2" "<0.001"
sex:diagnosis "3.777" "2" "0.151"
feature "0.086" "1" "0.769"
sex:feature "2.167" "1" "0.141"
diagnosis:feature "5.317" "2" "0.07"
sex:diagnosis:feature "1.735" "2" "0.42"
region "0.07" "2" "0.966"
sex:region "0.876" "2" "0.645"
diagnosis:region "6.121" "4" "0.19"
sex:diagnosis:region "1.532" "4" "0.821"
feature:region "0.652" "2" "0.722"
sex:feature:region "0.423" "2" "0.81"
diagnosis:feature:region "7.142" "4" "0.129"
sex:diagnosis:feature:region "2.274" "4" "0.686"
ANOVA-Type Statistic (ATS):
Test statistic df1 df2 p-value
sex "9.973" "1" "657.416" "0.002"
diagnosis "13.124" "1.343" "657.416" "<0.001"
sex:diagnosis "1.904" "1.343" "657.416" "0.164"
feature "0.086" "1" "Inf" "0.769"
sex:feature "2.167" "1" "Inf" "0.141"
diagnosis:feature "1.437" "1.562" "Inf" "0.238"
sex:diagnosis:feature "1.031" "1.562" "Inf" "0.342"
region "0.018" "1.611" "Inf" "0.965"
sex:region "0.371" "1.611" "Inf" "0.644"
diagnosis:region "1.091" "2.046" "Inf" "0.337"
sex:diagnosis:region "0.376" "2.046" "Inf" "0.691"
feature:region "0.126" "1.421" "Inf" "0.81"
sex:feature:region "0.077" "1.421" "Inf" "0.864"
diagnosis:feature:region "0.829" "1.624" "Inf" "0.415"
sex:diagnosis:feature:region "0.611" "1.624" "Inf" "0.51"
p-values resampling:
WildBS (WTS) WildBS (ATS)
sex "<0.001" "<0.001"
diagnosis "<0.001" "<0.001"
sex:diagnosis "0.119" "0.124"
feature "0.798" "0.798"
sex:feature "0.152" "0.152"
diagnosis:feature "0.067" "0.249"
sex:diagnosis:feature "0.445" "0.362"
region "0.967" "0.98"
sex:region "0.691" "0.728"
diagnosis:region "0.182" "0.338"
sex:diagnosis:region "0.863" "0.814"
feature:region "0.814" "0.926"
sex:feature:region "0.881" "0.951"
diagnosis:feature:region "0.098" "0.519"
sex:diagnosis:feature:region "0.764" "0.683"
We find significant effects at level
The RM()
function is equipped with a plotting option, displaying the
calculated means along with RM
object as argument. In
addition, the factor of interest may be specified. If this argument is
omitted in a two- or higher-way layout, the user is asked to specify the
factor for plotting. Furthermore, additional graphical parameters can be
used to customize the plots. The optional argument legendpos
specifies
the position of the legend in higher-way layouts, whereas gap
(default
0.1) is the distance introduced between error bars in a higher-way
layout. Additionally, the parameter CI.info
can be set to TRUE
in
order to output the means and confidence intervals for the desired
interaction.
R> plot(EEG_model, factor = "sex", main = "Effect of sex on EEG values")
R> plot(EEG_model, factor = "sex:diagnosis", legendpos = "topleft",
+ col = c(4, 2), ylim = c(-1.8, 0.8), CI.info = TRUE)
$mean
AD MCI SCC
M -1.1496245 -0.43724352 0.3114978
W -0.1723434 0.01624054 0.4897902
$lower
AD MCI SCC
M -1.6714757 -0.6251940 0.1732354
W -0.3874841 -0.1290226 0.3848516
$upper
AD MCI SCC
M -0.62777339 -0.2492930 0.4497601
W 0.04279732 0.1615037 0.5947288
R> plot(EEG_model, factor = "sex:diagnosis:feature",
+ legendpos = "bottomright", gap = 0.05)
The resulting plots are displayed in Figure 1 and Figure 2, respectively.
For the analysis of multivariate data, the functions MANOVA
and
MANOVA.wide
are implemented. The difference between the two functions
is that the response must be stored in long and wide format for using
MANOVA
or MANOVA.wide
, respectively. The structure of both functions
is very similar. They both calculate the WTS for multivariate data in a
design with crossed or nested factors. Additionally, the modified
ANOVA-type statistic (MATS) is calculated which has the additional
advantage of being applicable to designs involving singular covariance
matrices and is invariant under scale transformations of the data
(Friedrich and Pauly 2018). The resampling methods provided are a parametric
bootstrap approach and a wild bootstrap using Rademacher weights. Note
that only balanced nested designs (i.e., the same number of factor
levels nested.levels.unique
to TRUE
.
R> MANOVA(formula, data, subject, iter = 10000, alpha = 0.05,
+ resampling = "paramBS", CPU, seed,
+ nested.levels.unique = FALSE, dec = 3)
R> MANOVA.wide(formula, data, iter = 10000, alpha = 0.05,
+ resampling = "paramBS", CPU, seed,
+ nested.levels.unique = FALSE, dec = 3)
The only difference between MANOVA
and MANOVA.wide
in the function
call except from the different shape of the formula (see examples below)
is the subject
variable, which needs to be specified for MANOVA
only.
We again consider the data set EEG
from the MANOVA.RM package, but
now we ignore the within subject factor structure. Therefore, we are now
in a multivariate setting with 6 measurements per patient and three
crossed factors sex, age and diagnosis. Due to the small number of
subjects in some groups we restrict our analyses to two factors at a
time. The analysis of this example is shown below.
R> data("EEG")
R> EEG_MANOVA <- MANOVA(resp ~ sex * diagnosis, data = EEG, subject = "id",
+ resampling = "paramBS", iter = 1000, alpha = 0.01,
+ CPU = 1, seed = 987)
R> summary(EEG_MANOVA)
Call:
resp ~ sex * diagnosis
Descriptive:
sex diagnosis n Mean 1 Mean 2 Mean 3 Mean 4 Mean 5 Mean 6
1 M AD 12 -0.987 -1.007 -1.010 -1.320 -1.086 -1.488
3 M MCI 27 -0.506 -0.464 -0.447 -0.490 -0.459 -0.257
5 M SCC 20 0.409 0.243 0.459 0.314 0.095 0.349
2 W AD 24 -0.285 -0.159 -0.294 -0.194 0.026 -0.128
4 W MCI 30 -0.069 -0.074 -0.106 0.121 0.131 0.094
6 W SCC 47 0.559 0.548 0.537 0.506 0.403 0.384
Wald-Type Statistic (WTS):
Test statistic df p-value
sex "12.604" "6" "0.05"
diagnosis "55.158" "12" "<0.001"
sex:diagnosis "9.79" "12" "0.634"
modified ANOVA-Type Statistic (MATS):
Test statistic
sex 45.263
diagnosis 194.165
sex:diagnosis 18.401
p-values resampling:
paramBS (WTS) paramBS (MATS)
sex "0.124" "0.003"
diagnosis "<0.001" "<0.001"
sex:diagnosis "0.748" "0.223"
The output consists of several parts: First, some descriptive statistics
of the data set are displayed, namely the sample size and mean for each
factor level combination and each dimension (dimensions occur in the
same order as in the original data set). In this example, Mean 1 to Mean
3 correspond to the brainrate (temporal, frontal, central) while Mean
4–6 correspond to complexity. Second, the results based on the WTS are
displayed. For each factor, the test statistic, degree of freedom and
To demonstrate the use of the MANOVA.wide()
function, we consider the
same data set in wide format, which is also included in the package. In
the formula argument, the user now needs to specify the variables of
interest bound together via cbind
. A subject variable is no longer
necessary, as every row of the data set belongs to one patient in wide
format data. The output is almost identically to the one obtained from
MANOVA
with the difference that the mean values are now labeled
according to the variable names supplied in the formula
argument.
R> data("EEGwide")
R> EEG_wide <- MANOVA.wide(cbind(brainrate_temporal, brainrate_frontal,
+ brainrate_central, complexity_temporal,
+ complexity_frontal, complexity_central) ~ sex * diagnosis,
+ data = EEGwide, resampling = "paramBS", iter = 1000,
+ alpha = 0.01, CPU = 1, seed = 987)
R> summary(EEG_wide)
Call:
cbind(brainrate_temporal, brainrate_frontal, brainrate_central,
complexity_temporal, complexity_frontal, complexity_central) ~
sex * diagnosis
Descriptive:
sex diagnosis n brainrate_temporal brainrate_frontal brainrate_central
1 M AD 12 -0.987 -1.007 -1.010
2 W AD 27 -0.506 -0.464 -0.447
3 M MCI 20 0.409 0.243 0.459
4 W MCI 24 -0.285 -0.159 -0.294
5 M SCC 30 -0.069 -0.074 -0.106
6 W SCC 47 0.559 0.548 0.537
complexity_temporal complexity_frontal complexity_central
1 -1.320 -1.086 -1.488
2 -0.490 -0.459 -0.257
3 0.314 0.095 0.349
4 -0.194 0.026 -0.128
5 0.121 0.131 0.094
6 0.506 0.403 0.384
Wald-Type Statistic (WTS):
Test statistic df p-value
sex "12.604" "6" "0.05"
diagnosis "55.158" "12" "<0.001"
sex:diagnosis "9.79" "12" "0.634"
modified ANOVA-Type Statistic (MATS):
Test statistic
sex 45.263
diagnosis 194.165
sex:diagnosis 18.401
p-values resampling:
paramBS (WTS) paramBS (MATS)
sex "0.122" "0.005"
diagnosis "<0.001" "<0.001"
sex:diagnosis "0.742" "0.21"
In this example, MATS detects a significant effect of sex, a finding
that is not shared by the
The MANOVA
functions are equipped with a function for calculating and
plotting of confidence regions. Details on the methods can be found in
Friedrich and Pauly (2018). We would like to point out, however, that the MATS-based
confidence regions have to be interpreted differently from the more
usual WTS-based ones. For the latter, the WTS is compared to a fixed
critical value (in the asymptotic choice from a conf.reg
function. Note that confidence regions can only be plotted in designs
with 2 dimensions.
R> conf.reg(object, nullhypo)
Object
must be an object of class "MANOVA"
, i.e., created using
either MANOVA
or MANOVA.wide
, whereas nullhypo
specifies the
desired null hypothesis, i.e., the contrast of interest in designs
involving more than one factor. As an example, we consider the data set
water from the HSAUR
package (Everitt and Hothorn 2017). The data set contains measurements of mortality and
drinking water hardness for 61 cities in England and Wales. Suppose we
want to analyse whether these measurements differ between northern and
southern towns. Since the data set is in wide format, we need to use the
MANOVA.wide
function.
R> library("HSAUR")
R> data("water")
R> test <- MANOVA.wide(cbind(mortality, hardness) ~ location, data = water,
+ iter = 1000, resampling = "paramBS", CPU = 1, seed = 123)
R> summary(test)
R> cr <- conf.reg(test)
R> cr
R> plot(cr, xlab = "Difference in mortality",
+ ylab ="Difference in water hardness")
Call:
cbind(mortality, hardness) ~ location
Descriptive:
location n mortality hardness
1 North 35 1633.600 30.400
2 South 26 1376.808 69.769
Wald-Type Statistic (WTS):
Test statistic df p-value
location "51.584" "2" "<0.001"
modified ANOVA-Type Statistic (MATS):
Test statistic
location 69.882
p-values resampling:
paramBS (WTS) paramBS (MATS)
location "<0.001" "<0.001"
We find significant differences in mortality and water hardness between northern and southern towns.
The confidence region is returned as an ellipsoid specified by its
center as well as its axes, which extend Scale
units into the
direction of the respective eigenvector. For two-dimensional outcomes as
in this example, the confidence ellipsoid can also be plotted using the
ellipse package
(Murdoch and Chow 2018), see Figure 3.
Center:
[,1]
[1,] 256.792
[2,] -39.369
Scale:
[1] 10.852716 2.736354
Eigenvectors:
[,1] [,2]
[1,] -1 0
[2,] 0 -1
To create a data example for a nested design, we use the curdies
data
set from the GFD package and extend it by introducing an artificial
second outcome variable. In this data set, the levels of the nested
factor (site) are named uniquely, i.e., levels 1-3 of factor site belong
to "WINTER", whereas levels 4-6 belong to "SUMMER". Therefore,
nested.levels.unique
must be set to TRUE
. The code for the analysis
using both wide and long format is presented below.
R> library("GFD")
R> data("curdies")
R> set.seed(123)
R> curdies$dug2 <- curdies$dugesia + rnorm(36)
R> # first possibility: MANOVA.wide
R> fit1 <- MANOVA.wide(cbind(dugesia, dug2) ~ season + season:site,
+ data = curdies, iter = 1000,
+ nested.levels.unique = TRUE, seed = 123, CPU = 1)
R> # second possibility: MANOVA (long format)
R> dug <- c(curdies$dugesia, curdies$dug2)
R> season <- rep(curdies$season, 2)
R> site <- rep(curdies$site, 2)
R> curd <- data.frame(dug, season, site, subject = rep(1:36, 2))
R> fit2 <- MANOVA(dug ~ season + season:site, data = curd,
+ subject = "subject", nested.levels.unique = TRUE,
+ seed = 123, iter = 1000, CPU = 1)
R> # comparison of results
R> summary(fit1)
R> summary(fit2)
Call:
cbind(dugesia, dug2) ~ season + season:site
Descriptive:
season site n dugesia dug2
1 SUMMER 4 6 0.419 -0.050
2 SUMMER 5 6 0.229 0.028
3 SUMMER 6 6 0.194 0.763
4 WINTER 1 6 2.049 2.497
5 WINTER 2 6 4.182 4.123
6 WINTER 3 6 0.678 0.724
Wald-Type Statistic (WTS):
Test statistic df p-value
season 6.999 2 0.030
season:site 16.621 8 0.034
modified ANOVA-Type Statistic (MATS):
Test statistic
season 12.296
season:site 15.064
p-values resampling:
paramBS (WTS) paramBS (MATS)
season 0.064 0.032
season:site 0.275 0.216
Call:
dug ~ season + season:site
Descriptive:
season site n Mean 1 Mean 2
1 SUMMER 4 6 0.419 -0.050
2 SUMMER 5 6 0.229 0.028
3 SUMMER 6 6 0.194 0.763
4 WINTER 1 6 2.049 2.497
5 WINTER 2 6 4.182 4.123
6 WINTER 3 6 0.678 0.724
Wald-Type Statistic (WTS):
Test statistic df p-value
season 6.999 2 0.030
season:site 16.621 8 0.034
modified ANOVA-Type Statistic (MATS):
Test statistic
season 12.296
season:site 15.064
p-values resampling:
paramBS (WTS) paramBS (MATS)
season 0.064 0.032
season:site 0.275 0.216
In addition to global testing, the package MANOVA.RM allows for post-hoc comparisons. In particular, the following comparisons are implemented:
calculation of simultaneous multivariate
calculation of simultaneous confidence intervals based on summary effects (i. e. averaged across all dimensions) and
univariate comparisons for separate endpoints.
Calculation of simultaneous confidence intervals and simCI
, which is build on
contrMat
from the
multcomp package
(Hothorn et al. 2008b):
simCI(object, contrast, contmat, type, base)
Here, object
is an object of class "MANOVA"
. The user can choose
between pairwise or user-defined contrasts. For user-defined constrast
(contrast = "user-defined"
), the contrast matrix of interest must be
specified in contmat
. Pairwise comparisons (contrast = "pairwise"
)
are calculated using the contrMat
function of multcomp and
accordingly, type
and base
specify the type of the pairwise
comparison and the baseline group for Dunnett contrasts, see (Hothorn et al. 2008b)
for details on these parameters. To exemplify its application we
reconsider the EEG example from above:
R> # pairwise comparison using Tukey contrasts
R> simCI(EEG_MANOVA, contrast = "pairwise", type = "Tukey")
#------ Call -----#
- Contrast: Tukey
- Confidence level: 99 %
#------Multivariate post-hoc comparisons: p-values -----#
contrast p.value
1 M MCI - M AD 0.961
2 M SCC - M AD 0.548
3 W AD - M AD 0.899
4 W MCI - M AD 0.775
5 W SCC - M AD 0.417
6 M SCC - M MCI 0.368
7 W AD - M MCI 0.995
8 W MCI - M MCI 0.843
9 W SCC - M MCI 0.111
10 W AD - M SCC 0.845
11 W MCI - M SCC 0.938
12 W SCC - M SCC 0.989
13 W MCI - W AD 1.000
14 W SCC - W AD 0.526
15 W SCC - W MCI 0.563
#-----------Confidence intervals for summary effects-------------#
Estimate Lower Upper
M MCI - M AD 4.275 -16.181707 24.731707
M SCC - M AD 8.767 -11.126510 28.660510
W AD - M AD 5.864 -14.947797 26.675797
W MCI - M AD 6.995 -12.978374 26.968374
W SCC - M AD 9.835 -9.799574 29.469574
M SCC - M MCI 4.492 -4.040216 13.024216
W AD - M MCI 1.589 -8.907565 12.085565
W MCI - M MCI 2.720 -5.996803 11.436803
W SCC - M MCI 5.560 -2.349709 13.469709
W AD - M SCC -2.903 -12.254617 6.448617
W MCI - M SCC -1.772 -9.069776 5.525776
W SCC - M SCC 1.068 -5.243764 7.379764
W MCI - W AD 1.131 -8.389330 10.651330
W SCC - W AD 3.971 -4.816350 12.758350
W SCC - W MCI 2.840 -3.719140 9.399140
The output is two-fold: First, the multivariate
As another example using a user-defined contrast matrix, we consider the following one-way layout of the EEG data:
R> oneway <- MANOVA.wide(cbind(brainrate_temporal, brainrate_central)
+ ~ diagnosis, data = EEGwide, iter = 1000,
+ CPU = 1)
R> # a user-defined contrast matrix
R> H <- as.matrix(cbind(rep(1, 5), -1*Matrix::Diagonal(5)))
R> simCI(oneway, contrast = "user-defined", contmat = H)
#------ Call -----#
- Contrast: user-defined
- Confidence level: 95 %
#------Multivariate post-hoc comparisons: p-values -----#
[1] 1.000 0.673 0.655 0.008 0.008
#-----------Confidence intervals for summary effects-------------#
Estimate Lower Upper
1 0.013 -1.003489 1.0294895
2 -0.243 -1.050099 0.5640992
3 -0.251 -1.058376 0.5563761
4 -1.033 -1.812577 -0.2534227
5 -1.033 -1.791749 -0.2742508
Note that interpretation of the results depends on the user-defined contrast matrix.
If the global null hypothesis, e. g.
R> EEG1 <- MANOVA.wide(brainrate_temporal ~ diagnosis, data = EEGwide,
+ iter = 1000, seed = 987, CPU = 1)
R> EEG2 <- MANOVA.wide(brainrate_central ~ diagnosis, data = EEGwide,
+ iter = 1000, seed = 987, CPU = 1)
R> p.adjust(c(EEG1$resampling[, 2], EEG2$resampling[, 2]),
+ method = "bonferroni")
[1] 0 0
Thus, in this example both endpoints showed significant effects.
Note that it is often possible to conduct post-hoc comparisons according
to the closure principle, thus avoiding the need to correct for multiple
comparisons. Implementation of these methods for both MANOVA and RM
designs is part of future research.
The GUI is started in R with the command GUI.RM()
, GUI.MANOVA()
and
GUI.MANOVAwide()
for repeated measures designs and multivariate data
in long or wide format, respectively. Note that the GUI depends on
RGtk2 and will only work if RGtk2 is installed. The user can specify
the data location (either directly or via the "load data" button) and
the formula as well as the number of iterations, the significance level
R> library("MANOVA.RM")
R> GUI.RM()
We have explicitly described the usage of the R package MANOVA.RM for analyzing various nonparametric multivariate MANOVA and RM designs making use of novel bootstrap- and permutation-approaches. Moreover, the corresponding models and inference procedures that have been derived and theoretically analyzed in previous papers are explained as well. In particular, three different test statistics of Wald-, ANOVA- and modified ANOVA-type are implemented together with appropriate critical values derived from asymptotic considerations, approximations or novel resampling approaches. Here, the latter is recommended in case of small to moderate sample sizes. All methods can be applied without assuming usual presumptions such as multivariate normality or specific covariance structures. Moreover, all procedures are particularly constructed to tackle covariance matrix heterogeneity across groups or even covariance singularity (in case of the MATS). In this way MANOVA.RM provides a flexible tool box for inferring hypotheses about (i) main and interaction effects in general factorial MANOVA and (ii) between and within subject effects in RM designs with possibly complex factorial structures on both, between and within subject factors.
In addition, we have placed a graphical user interface (GUI) at the users disposal to allow for a simple and intuitive use. It is planned to update the package on a regular basis; respecting the development of new procedures for general RM and MANOVA designs. For example, our working group is currently investigating the implementation of covariates in the above model in theoretical research and the resulting procedure may be incorporated in the future. Other topics include the possible implementation/improvement of subsequent multiple comparisons by the closure principle, as in (Burchett et al. 2017), for both MANOVA and RM designs.
The work of Sarah Friedrich and Markus Pauly was supported by the German Research Foundation project DFG-PA 2409/3-1.
stats, npmv, nparLD, GFD, SCGLR, car, flip, ffmanova, MANOVA.RM, RGtk2, plotrix, HSAUR, ellipse, multcomp
ClinicalTrials, Econometrics, Finance, MixedModels, Survival, TeachingStatistics
This article is converted from a Legacy LaTeX article using the texor package. The pdf version is the official version. To report a problem with the html, refer to CONTRIBUTE on the R Journal homepage.
Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".
For attribution, please cite this work as
Friedrich, et al., "Resampling-Based Analysis of Multivariate Data and Repeated Measures Designs with the R Package MANOVA.RM", The R Journal, 2019
BibTeX citation
@article{RJ-2019-051, author = {Friedrich, Sarah and Konietschke, Frank and Pauly, Markus}, title = {Resampling-Based Analysis of Multivariate Data and Repeated Measures Designs with the R Package MANOVA.RM}, journal = {The R Journal}, year = {2019}, note = {https://rjournal.github.io/}, volume = {11}, issue = {2}, issn = {2073-4859}, pages = {380-400} }