Package 'HRM'

Title: High-Dimensional Repeated Measures
Description: Methods for testing main and interaction effects in possibly high-dimensional parametric or nonparametric repeated measures in factorial designs. The observations of the subjects are assumed to be multivariate normal if using the parametric test. The nonparametric version tests with regard to nonparametric relative effects (based on pseudo-ranks). It is possible to use up to 2 whole- and 3 subplot factors. See Happ et al. (2017, <doi:10.1080/15598608.2017.1307792>) for details.
Authors: Martin Happ [aut, cre] (ORCID: <https://orcid.org/0000-0003-0009-2665>), Solomon W. Harrar [aut], Arne C. Bathke [aut]
Maintainer: Martin Happ <[email protected]>
License: GPL-2 | GPL-3
Version: 1.3.0
Built: 2026-10-12 10:12:33 UTC
Source: https://github.com/happma/hrm

Help Index


Inference on Low- and High-Dimensional Multi-Group Repeated Measures Designs with Unequal Covariance Matrices

Description

Tests for main and simple treatment effects, time effects, as well as treatment by time interactions in possibly high-dimensional multi-group repeated measures designs. The groups are allowed to have different variance-covariance matrices. The parametric test assumes the observations to follow a multivariate normal distribution; the nonparametric version tests with regard to nonparametric relative effects based on pseudo-ranks.

Author(s)

Martin Happ [email protected] (ORCID: https://orcid.org/0000-0003-0009-2665), Solomon W. Harrar, Arne C. Bathke.

Maintainer: Martin Happ [email protected]

References

Happ, M., Harrar, S. W. and Bathke, A. C. (2016). Inference for low- and high-dimensional multigroup repeated measures designs with unequal covariance matrices. Biometrical Journal, 58(4), 810–830. doi:10.1002/bimj.201500064

Happ, M., Harrar, S. W. and Bathke, A. C. (2017). High-dimensional Repeated Measures. Journal of Statistical Theory and Practice, 11(3), 468–477. doi:10.1080/15598608.2017.1307792

Happ, M., Harrar, S. W. and Bathke, A. C. (2018). HRM: An R Package for Analysing High-dimensional Multi-factor Repeated Measures. The R Journal, 10(1), 534–548. doi:10.32614/RJ-2018-032

Staffen, W., Strobl, N., Zauner, H., Hoeller, Y., Dobesberger, J. and Trinka, E. (2014). Combining SPECT and EEG analysis for assessment of disorders with amnestic symptoms to enhance accuracy in early diagnostics. Poster A19 presented at the 11th Annual Meeting of the Austrian Society of Neurology, 26th–29th March 2014, Salzburg, Austria.

See Also

hrm_test for the main function of the package.


Function to calculate confidence intervals

Description

Function to calculate simultaneous, asymptotic (1-alpha) confidence intervals for an object of class 'HRM'.

Usage

## S3 method for class 'HRM'
confint(object, parm, level = 0.95, ...)

Arguments

object

an object from class 'HRM' returned from the function hrm_test

parm

currently ignored; all possible confidence intervals are calculated

level

confidence level (FWER) used for calculating the inverals

...

Further arguments passed to 'hrm_test' will be ignored

Value

Returns a data.frame with mean and 1-alpha confidence interval for each factor level combination. The attribute "status" states which form of multiplicity control was used: family-wise error rate over all factor level combinations, family-wise error rate within each whole-plot group, a Sidak correction within each group, or none.

Examples

# using the EEG dataset
z <- hrm_test(value ~ dimension, subject = "subject", data = EEG)

# simultaneous confidence intervals for each factor level combination
ci <- confint(z)
head(ci)

# which form of multiplicity control was used
attr(ci, "status")


# With a whole-plot factor the correlation matrix can become large enough
# that mvtnorm::qmvnorm() fails. confint() then falls back to controlling
# the family-wise error rate within each group, or to a Sidak correction.
# The status says which of these was actually used.
z <- hrm_test(value ~ group*region*variable, subject = "subject", data = EEG)
ci <- confint(z, level = 0.99)
attr(ci, "status")

EEG data of 160 subjects

Description

A dataset containing EEG data (Staffen et al., 2014) of 160 subjects, 4 variables are measured at ten different locations.

Usage

data(EEG)

Format

A data frame with 6400 rows and 7 variables.

Details

The columns are as follows:

  • group. Diagnostic group of the subject: Alzheimer's Disease (AD), Mild Cognitive Impairment (MCI), Subject Cognitive Complaints (SCC+, SCC-).

  • value. Measured data of a subject at a specific variable and region.

  • sex. Sex of the subject: Male (M) or Female (W).

  • subject. A unique identification of a subject.

  • variable. The variales measured are activity, complexity, mobility and brain rate coded from 1 to 4.

  • region. Frontal left/right, central left/right, temporal left/right, occipital left/right, parietal left/right coded as 1 to 10.

  • dimension. Mixing variable and region together, levels range from 1 to 40.


Test for Multi-Factor High-Dimensional Repeated Measures

Description

Performing main and interaction effects of up to three whole- or subplot-factors. In total, a maximum of four factors can be used. There are two different S3 methods available. The first method requires a list of matrices in the wide table format. The second methodl requres a data.frame in the long table format.

Usage

hrm_test(data, ...)

## S3 method for class 'list'
hrm_test(data, alpha = 0.05, ...)

## S3 method for class 'data.frame'
hrm_test(
  data,
  formula,
  alpha = 0.05,
  subject,
  nonparametric = FALSE,
  np.correction = NA,
  character.only = FALSE,
  ...
)

Arguments

data

Either a data.frame (one observation per row) or a list with matrices (one subject per row) for all groups containing the data

...

Further arguments passed to 'hrm_test' will be ignored

alpha

alpha level used for calculating the critical value for the test

formula

A model formula object. The left hand side contains the response variable and the right hand side contains the whole- and subplot factors.

subject

column name within the data frame X identifying the subjects

nonparametric

Logical variable indicating wether the noparametric version of the test statistic should be used

np.correction

Logical variable indicating wether a small sample size correction for the nonparametric test should be used (TRUE) or not (FALSE). By using NA, np.correction is used automatically in an high-dimensional setting.

character.only

a logical indicating whether subject can be assumed to be a character string

Value

Returns an object from class HRM containing

result

A dataframe with the results from the hypotheses tests.

formula

The formula object which was used.

alpha

The type-I error rate which was used.

subject

The column name identifying the subjects.

factors

A list containing the whole- and subplot factors.

data

The data.frame or list containing the data.

Examples

## hrm_test with a list of matrices

# number patients per group
n = c(10,10)
# number of groups
a=2
# number of variables
d=40

# defining the list consisting of the samples from each group
mu_1 = mu_2 = rep(0,d)
# autoregressive covariance matrix
sigma_1 = diag(d)
for(k in 1:d) for(l in 1:d) sigma_1[k,l] = 1/(1-0.5^2)*0.5^(abs(k-l))
sigma_2 = 1.5*sigma_1
X = list(MASS::mvrnorm(n[1],mu_1, sigma_1), MASS::mvrnorm(n[2],mu_2, sigma_2))
X=lapply(X, as.matrix)

hrm_test(data=X, alpha=0.05)


## hrm.test with a data.frame using a 'formula' object

# using the EEG dataset
hrm_test(value ~ group*region*variable, subject = "subject", data = EEG)

Plotting Profile Curves

Description

Plotting profile curves for up to one whole- or subplot-factor

Usage

## S3 method for class 'HRM'
plot(x, xlab = "time", ylab = "mean", legend = TRUE, legend.title = "", ...)

Arguments

x

An object of class 'HRM' from the function 'hrm_test'

xlab

label of the x-axis of the plot

ylab

label of the y-axis of the plot

legend

logical indicating if a legend should be plotted

legend.title

title of the legend

...

Further arguments passed to the 'plot' function

Value

An object of class 'ggplot' containing the profile plot of the group means, which can be printed or further modified with 'ggplot2' functions.

Examples

data(EEG)
head(EEG)

# plots profiles according to groups with
# subplot-factor called dimension

# first create an HRM object
object_hrm <- hrm_test(value ~ group*dimension, subject = "subject", data = EEG)

# plot the HRM object, here we use the additional argument 'theme_bw()' for ggplot2
plot(object_hrm, legend = TRUE, legend.title = "Group", ... =  ggplot2::theme_bw() )

# same plot without a legend
# note that 'theme_bw' overwrites the standard legend properties of plot.HRM
plot(object_hrm, ... =  ggplot2::theme_bw() +
  ggplot2::theme(legend.title = ggplot2::element_blank(), legend.position="none") )