Learn R Programming

HRM 1.2.0

R package for analysing high-dimensional repeated measures for factorial designs. A description of this package can be found in [1], theoretical derivations of the test statistics are in [2] and [3].

To install the current development version:

## install devtools package
if (!requireNamespace("devtools", quietly = TRUE)) {
  install.packages("devtools")
}
# install package
devtools::install_github("happma/HRM", ref = "test", dependencies = TRUE)
library(HRM)

With this package it is possible to test for 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 method requires a data.frame in the long table format.

## 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(mvrnorm(n[1],mu_1, sigma_1), 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)

To get confidence intervals for each factor combination you can use the generic function 'confint' for an object of class 'HRM'. This function calculates simultaneous confidence intervals which maintains the family wise error rate (FWER). See the following code:

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

# calculate 99% confidence intervals
confint(z, level = 0.99)

In the data there are 4 variables with each 10 regions. We can use a multivariate approach as the variables are on different scales. For that, we can use the function 'hrm_test' with the argument 'variable' set to the column name which contains the factor variable for the variables.

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

Additionally, the package can be used with a GUI.

hrm_GUI()

References

[1] 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. https://journal.r-project.org/archive/2018/RJ-2018-032/index.html

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

[3] Happ, M., Harrar, S. W., & 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

Copy Link

Version

Install

install.packages('HRM')

Monthly Downloads

73

Version

1.2.1

License

GPL-2 | GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Martin Happ

Last Published

February 6th, 2020

Functions in HRM (1.2.1)

.E1

Unbiased estimator
DualEmpirical2

Function for the dual empirical matrix
hrm.AB

Test for no interaction between treatment and time
hrm.plot

Plots profiles of the groups in case of one whole- and one subplot-factor.
hrm.0w.2s

Test for interaction of factor A and B
gui.results

Function for displaying and saving the results of the function 'hrm_test' within the function 'hrm.GUI'
.hrm.sigcode

Function for the output: significant p-values have on or more stars
hrm.1w.2f

Test for interaction of factor A and B
hrm.A.weighted

Test for no main treatment effect (weighted version)
hrm.GUI

Graphical User Interface for Testing Multi-Factor High-Dimensional Repeated Measures
hrm.0w.3s

Test for interaction of factor A and B
hrm.0w.4s

Test for interaction of four subplot factors
hrm.1w.1f

Test for interaction of factor A and B
hrm.test.2.two

Test for two subplot factors
hrm.test.matrices

Test for no main treatment effect, no main time effect, no simple treatment effect and no interaction between treatment and time
hrm.mv.internal

MVHRM test
hrm.mv.1w.1f

MVHRM test
.E4

Unbiased estimator
hrm.1w.3f

Test for 1 wholeplot and 3 subplot-factors
.E2

Unbiased estimator
hrm.test.2.one

Test for no main effects and interactino effects of one between-subject factor and one crossed within-subject factors
hrm.test.matrix-deprecated

hrm.test.matrix
hrm.test.3.three

Test for two subplot factors
.E3

Unbiased estimator
hrm.B

Test for no main time effect
hrm.2w.1f

Test for influence of factor A
hrm.0w.5s

Test for interaction of four subplot factors
hrm.test.1.one

Test for one subplot factor
hrm.test.2.between

Test for no main effects and interaction effects of two crossed between-subject factors and one within-subject factor
hrm.test.2.within

Test for no main effects and interactino effects of one between-subject factor and two crossed within-subject factors
hrm.test.1.none

Test for main group effect (weighted/unweighted)
hrm.test.2.between.within

Test for no main effects and interaction effects of two crossed between-subject factors and one within-subject factor
hrm.A_B

Test for no simple treatment effect
hrm.1f

Test for interaction of factor A and B
hrm_test_internal

Test for Multi-Factor High-Dimensional Repeated Measures
hrm.2w.2f

Test for influence of factor A
hrm.test.5.five

Test for two subplot factors
hrm.1w.0f

Test for interaction of factor A and B
hrm.A.unweighted

Test for no main treatment effect (unweighted version)
hrm.test.3.between

Test for no main effects and interaction effects of two crossed between-subject factors and one within-subject factor
hrm.test.4.four

Test for two subplot factors
plot.HRM

Plotting Profile Curves
hrm_test

Test for Multi-Factor High-Dimensional Repeated Measures
hrm_GUI

Graphical User Interface for Testing Multi-Factor High-Dimensional Repeated Measures
hrm.test.dataframe-deprecated

hrm.test.dataframe
DualEmpirical

Function for the dual empirical matrix
P

Function for the centering matrix
confint.HRM

Function to calculate confidence intervals
I

Function for the indentity matrix
J

Function for a matrix with entries 1
EEG

EEG data of 160 subjects
HRM-package

Inference on low- and high-dimensional multi-group reapeted-measures designs with unequal covariance matrices.
GUI_error

Function for presenting error messages to the user
HRM-deprecated

Deprecated functions in package HRM.