Package {HRM}


Version: 1.3.0
Date: 2026-08-31
Title: High-Dimensional Repeated Measures
Maintainer: Martin Happ <statistics@happ.co.at>
LazyData: true
Depends: R (≥ 4.2.0)
Imports: ggplot2, matrixcalc, plyr, data.table, doBy, mvtnorm, Rcpp (≥ 0.12.16), pseudorank (≥ 0.3.7)
Suggests: MASS, testthat
LinkingTo: Rcpp
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.
Encoding: UTF-8
License: GPL-2 | GPL-3
RoxygenNote: 7.3.2
URL: https://github.com/happma/HRM
BugReports: https://github.com/happma/HRM/issues
NeedsCompilation: yes
Packaged: 2026-08-31 17:44:29 UTC; happma
Author: Martin Happ ORCID iD [aut, cre], Solomon W. Harrar [aut], Arne C. Bathke [aut]
Repository: CRAN
Date/Publication: 2026-09-11 14:00:02 UTC

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 statistics@happ.co.at (ORCID: https://orcid.org/0000-0003-0009-2665), Solomon W. Harrar, Arne C. Bathke.

Maintainer: Martin Happ statistics@happ.co.at

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.


Unbiased estimator

Description

Unbiased estimator

Usage

.E1(n, i, M, nonparametric, Q)

Arguments

n

vector of sample size

i

group index

M

a matrix


Unbiased estimator

Description

Unbiased estimator

Usage

.E2(n, i, M, nonparametric, Q)

Arguments

n

vector of sample size

i

group index

M

a matrix


Unbiased estimator

Description

Unbiased estimator

Usage

.E3(M_i, M_j)

Arguments

M_i

a matrix for group i

M_j

a matrix for group j


Unbiased estimator

Description

Unbiased estimator

Usage

.E4(M_i, M_j)

Arguments

M_i

a matrix for group i

M_j

a matrix for group j


Function for the output: significant p-values have on or more stars

Description

Function for the output: significant p-values have on or more stars

Usage

.hrm.sigcode(value)

Arguments

value

p-value


Function for the dual empirical matrix

Description

Function for the dual empirical matrix

Usage

DualEmpirical(Data, B)

Arguments

Data

data.frame

B

not used


Function for the dual empirical matrix

Description

Function for the dual empirical matrix

Usage

DualEmpirical2(Data, B)

Arguments

Data

data.frame

B

part of the hypothesis matrix


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:


Deprecated functions in package HRM.

Description

The functions listed below are deprecated and will be defunct in the near future. When possible, alternative functions with similar functionality are also mentioned. Help pages for deprecated functions are available at help("hrm.test.matrix-deprecated") and help("hrm.test.dataframe-deprecated").

Usage

hrm.test.matrix(data, alpha = 0.05)

hrm.test.dataframe(
  data,
  alpha = 0.05,
  group,
  subgroup,
  factor1,
  factor2,
  factor3,
  subject,
  response
)

Details

For hrm.test.dataframe and hrm.test.matrix use hrm_test instead.

Value

hrm.test.matrix and hrm.test.dataframe both return an object of class 'HRM', exactly as returned by hrm_test.


Function for the indentity matrix

Description

Function for the indentity matrix

Usage

I(size)

Arguments

size

dimension of the matrix


Function for a matrix with entries 1

Description

Function for a matrix with entries 1

Usage

J(size)

Arguments

size

dimension of the matrix


Function for the centering matrix

Description

Function for the centering matrix

Usage

P(size)

Arguments

size

dimension of the matrix


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")


Test for interaction of factor A and B

Description

Test for interaction of factor A and B

Usage

hrm.0w.2s(
  X,
  alpha,
  factor1,
  factor2,
  subject,
  data,
  H = "B",
  text = "",
  nonparametric,
  ranked,
  varQGlobal,
  np.correction,
  tmpQ1g,
  tmpQ2g
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

factor1

column name of the data frame X of the first factor variable

subject

column name of the data frame X identifying the subjects

data

column name of the response variable

H

string specifying the hypothesis

text

a string, which will be printed in the output

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for interaction of factor A and B

Description

Test for interaction of factor A and B

Usage

hrm.0w.3s(
  X,
  alpha,
  factor1,
  factor2,
  factor3,
  subject,
  data,
  H = 1,
  text = "",
  nonparametric,
  ranked,
  varQGlobal,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

factor1

column name of the data frame X of the first factor variable

subject

column name of the data frame X identifying the subjects

data

column name of the response variable

H

string specifying the hypothesis

text

a string, which will be printed in the output

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for interaction of four subplot factors

Description

Test for interaction of four subplot factors

Usage

hrm.0w.4s(
  X,
  alpha,
  factor1,
  factor2,
  factor3,
  factor4,
  subject,
  data,
  H = 1,
  text = "",
  nonparametric,
  ranked,
  varQGlobal,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

factor1

column name of the data frame X of the first factor variable

subject

column name of the data frame X identifying the subjects

data

column name of the response variable

H

string specifying the hypothesis

text

a string, which will be printed in the output

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for interaction of four subplot factors

Description

Test for interaction of four subplot factors

Usage

hrm.0w.5s(
  X,
  alpha,
  factor1,
  factor2,
  factor3,
  factor4,
  factor5,
  subject,
  data,
  H = 1,
  text = "",
  nonparametric,
  ranked,
  varQGlobal,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

factor1

column name of the data frame X of the first factor variable

subject

column name of the data frame X identifying the subjects

data

column name of the response variable

H

string specifying the hypothesis

text

a string, which will be printed in the output

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for interaction of factor A and B

Description

Test for interaction of factor A and B

Usage

hrm.1f(
  X,
  alpha,
  factor1,
  subject,
  data,
  H = "B",
  text = "",
  nonparametric,
  ranked,
  varQGlobal,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

factor1

column name of the data frame X of the first factor variable

subject

column name of the data frame X identifying the subjects

data

column name of the response variable

H

string specifying the hypothesis

text

a string, which will be printed in the output

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for interaction of factor A and B

Description

Test for interaction of factor A and B

Usage

hrm.1w.0f(
  X,
  alpha,
  group,
  subject,
  data,
  H,
  text,
  nonparametric,
  ranked,
  varQGlobal
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

group

column name of the data frame X specifying the groups

subject

column name of the data frame X identifying the subjects

data

column name of the response variable

H

string specifying the hypothesis

text

a string, which will be printed in the output

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for interaction of factor A and B

Description

Test for interaction of factor A and B

Usage

hrm.1w.1f(
  X,
  alpha,
  group,
  factor1,
  subject,
  data,
  H,
  text,
  nonparametric,
  ranked,
  varQGlobal,
  np.correction,
  tmpQ1g,
  tmpQ2g
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

group

column name of the data frame X specifying the groups

factor1

column name of the data frame X of the first factor variable

subject

column name of the data frame X identifying the subjects

data

column name of the response variable

H

string specifying the hypothesis

text

a string, which will be printed in the output

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for interaction of factor A and B

Description

Test for interaction of factor A and B

Usage

hrm.1w.2f(
  X,
  alpha,
  group,
  factor1,
  factor2,
  subject,
  data,
  H,
  text = "",
  nonparametric,
  ranked,
  varQGlobal,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

group

column name of the data frame X specifying the groups

factor1

column name of the data frame X of the first factor variable

factor2

column name of the data frame X of the second factor variable

subject

column name of the data frame X identifying the subjects

data

column name of the data frame X containing the measurement data

H

string specifying the hypothesis

text

a string, which will be printed in the output

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for 1 wholeplot and 3 subplot-factors

Description

Test for 1 wholeplot and 3 subplot-factors

Usage

hrm.1w.3f(
  X,
  alpha,
  group,
  factor1,
  factor2,
  factor3,
  subject,
  data,
  S,
  K1,
  K2,
  K3,
  hypothesis,
  nonparametric,
  ranked,
  varQGlobal,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

group

column name of the data frame X specifying the groups

factor1

column name of the data frame X of the first factor variable

factor2

column name of the data frame X of the second factor variable crossed with the first one

factor3

column name of the data frame X of the third factor variable crossed with the first one

subject

column name of the data frame X identifying the subjects

data

column name of the data frame X containing the observed values

S

Matrix for the wholeplot factor

K1

Matrix for the first subplot factor

K2

Matrix for the second subplot factor

K3

Matrix for the third subplot factor

hypothesis

String which is printed in the console as ouput to indicate which hypothesis is tested.

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for influence of factor A

Description

Test for influence of factor A

Usage

hrm.2w.1f(
  X,
  alpha,
  group,
  subgroup,
  factor,
  subject,
  data,
  H,
  text = "",
  nonparametric,
  ranked,
  varQGlobal,
  np.correction,
  tmpQ1g,
  tmpQ2g
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

group

column name of the data frame X specifying the groups

subgroup

column name of the subgroups (crossed with groups)

factor

column name of the data frame X of within-subject factor

subject

column name of the data frame X identifying the subjects

data

column name of the data frame X containing the measurement data

H

string specifying the hypothesis

text

a string, which will be printed in the output

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for influence of factor A

Description

Test for influence of factor A

Usage

hrm.2w.2f(
  X,
  alpha,
  group,
  subgroup,
  factor1,
  factor2,
  subject,
  data,
  H,
  text = "",
  nonparametric,
  ranked,
  varQGlobal,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

group

column name of the data frame X specifying the groups

subgroup

column name of the subgroups (crossed with groups)

subject

column name of the data frame X identifying the subjects

data

column name of the data frame X containing the measurement data

H

string specifying the hypothesis

text

a string, which will be printed in the output

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for no main treatment effect (unweighted version)

Description

Test for no main treatment effect (unweighted version)

Usage

hrm.A.unweighted(n, a, d, X, alpha, nonparametric = FALSE)

Arguments

n

an vector containing the sample sizes of all groups

a

number of groups

d

number of dimensions (time points)

X

list containing the data matrices of all groups

alpha

alpha level used for the test

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for no main treatment effect (weighted version)

Description

Test for no main treatment effect (weighted version)

Usage

hrm.A.weighted(n, a, d, X, alpha, nonparametric = FALSE)

Arguments

n

an vector containing the sample sizes of all groups

a

number of groups

d

number of dimensions (time points)

X

list containing the data matrices of all groups

alpha

alpha level used for the test

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for no interaction between treatment and time

Description

Test for no interaction between treatment and time

Usage

hrm.AB(n, a, d, X, alpha, nonparametric = FALSE)

Arguments

n

an vector containing the sample sizes of all groups

a

number of groups

d

number of dimensions (time points)

X

list containing the data matrices of all groups

alpha

alpha level used for the test

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for no simple treatment effect

Description

Test for no simple treatment effect

Usage

hrm.A_B(n, a, d, X, alpha, nonparametric = FALSE)

Arguments

n

an vector containing the sample sizes of all groups

a

number of groups

d

number of dimensions (time points)

X

list containing the data matrices of all groups

alpha

alpha level used for the test

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for no main time effect

Description

Test for no main time effect

Usage

hrm.B(n, a, d, X, alpha, nonparametric = FALSE)

Arguments

n

an vector containing the sample sizes of all groups

a

number of groups

d

number of dimensions (time points)

X

list containing the data matrices of all groups

alpha

alpha level used for the test

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Plots profiles of the groups in case of one whole- and one subplot-factor.

Description

Plots profiles of the groups in case of one whole- and one subplot-factor.

Usage

hrm.plot(
  data,
  group,
  factor1,
  subject,
  response,
  xlab = "time",
  ylab = "mean",
  legend = TRUE,
  legend.title = NULL
)

Arguments

data

A data.frame containing the data

group

column name within the data frame data specifying the groups

factor1

column name within the data frame data specifying the first subplot-factor

subject

column name within the data frame X identifying the subjects

response

column name within the data frame X containing the response variable

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

Value

Plots profiles of the groups.

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") )

Test for main group effect (weighted/unweighted)

Description

Test for main group effect (weighted/unweighted)

Usage

hrm.test.1.none(X, alpha, group, subject, data, formula, nonparametric)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

group

column name of the data frame X specifying the groups

subject

column name of the data frame X identifying the subjects

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for one subplot factor

Description

Test for one subplot factor

Usage

hrm.test.1.one(
  X,
  alpha,
  factor1,
  subject,
  data,
  formula,
  nonparametric,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

factor1

column name of the data frame X of the first factor variable

subject

column name of the data frame X identifying the subjects

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


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

Description

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

Usage

hrm.test.2.between(
  X,
  alpha,
  group,
  subgroup,
  factor,
  subject,
  data,
  testing = rep(1, 7),
  formula,
  nonparametric,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

group

column name of the data frame X specifying the groups

subgroup

column name of the subgroups (crossed with groups)

factor

column name of the data frame X of within-subject factor

subject

column name of the data frame X identifying the subjects

data

column name of the data frame X containing the measurement data

testing

vector specifying which hypotheses should be tested

formula

formula object from the user input

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


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

Description

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

Usage

hrm.test.2.between.within(
  X,
  alpha,
  group,
  subgroup,
  factor1,
  factor2,
  subject,
  data,
  testing = rep(1, 15),
  formula,
  nonparametric,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

group

column name of the data frame X specifying the groups

subgroup

column name of the subgroups (crossed with groups)

factor1

column name of the data frame X of the first within-subject factor

factor2

column name of the data frame X of the second within-subject factor

subject

column name of the data frame X identifying the subjects

data

column name of the data frame X containing the measurement data

testing

vector specifying which hypotheses should be tested

formula

formula object from the user input

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for no main effects and interactino effects of one between-subject factor and one crossed within-subject factors

Description

Test for no main effects and interactino effects of one between-subject factor and one crossed within-subject factors

Usage

hrm.test.2.one(
  X,
  alpha,
  group,
  factor1,
  subject,
  data,
  testing = rep(1, 4),
  formula,
  nonparametric,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

group

column name of the data frame X specifying the groups

factor1

column name of the data frame X of the first factor variable

subject

column name of the data frame X identifying the subjects

data

column name of the data frame X containing the measurement data

testing

vector specifying which hypotheses should be tested

formula

formula object from the user input

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for two subplot factors

Description

Test for two subplot factors

Usage

hrm.test.2.two(
  X,
  alpha,
  factor1,
  factor2,
  subject,
  data,
  formula,
  testing = rep(1, 3),
  nonparametric,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

factor1

column name of the data frame X of the first factor variable

factor2

column name of the data frame X of the second factor variable

subject

column name of the data frame X identifying the subjects

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for no main effects and interactino effects of one between-subject factor and two crossed within-subject factors

Description

Test for no main effects and interactino effects of one between-subject factor and two crossed within-subject factors

Usage

hrm.test.2.within(
  X,
  alpha,
  group,
  factor1,
  factor2,
  subject,
  data,
  testing = rep(1, 7),
  formula,
  nonparametric,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

group

column name of the data frame X specifying the groups

factor1

column name of the data frame X of the first factor variable

factor2

column name of the data frame X of the second factor variable

subject

column name of the data frame X identifying the subjects

data

column name of the data frame X containing the measurement data

testing

vector specifying which hypotheses should be tested

formula

formula object from the user input

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


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

Description

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

Usage

hrm.test.3.between(
  X,
  alpha,
  group,
  factor1,
  factor2,
  factor3,
  subject,
  data,
  testing = rep(1, 15),
  formula,
  nonparametric,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

group

column name of the data frame X specifying the groups

factor1

column name of the data frame X of the first within-subject factor

factor2

column name of the data frame X of the second within-subject factor

factor3

column name of the data frame X of the third within-subject factor

subject

column name of the data frame X identifying the subjects

data

column name of the data frame X containing the measurement data

testing

vector specifying which hypotheses should be tested

formula

formula object from the user input

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for two subplot factors

Description

Test for two subplot factors

Usage

hrm.test.3.three(
  X,
  alpha,
  factor1,
  factor2,
  factor3,
  subject,
  data,
  formula,
  testing = rep(1, 7),
  nonparametric,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

factor1

column name of the data frame X of the first factor variable

factor2

column name of the data frame X of the second factor variable

factor3

column name of the data frame X of the third factor variable

subject

column name of the data frame X identifying the subjects

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for two subplot factors

Description

Test for two subplot factors

Usage

hrm.test.4.four(
  X,
  alpha,
  factor1,
  factor2,
  factor3,
  factor4,
  subject,
  data,
  formula,
  testing = rep(1, 2^4 - 1),
  nonparametric,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

factor1

column name of the data frame X of the first factor variable

factor2

column name of the data frame X of the second factor variable

factor3

column name of the data frame X of the third factor variable

factor4

column name of the data frame X of the fourth factor variable

subject

column name of the data frame X identifying the subjects

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


Test for two subplot factors

Description

Test for two subplot factors

Usage

hrm.test.5.five(
  X,
  alpha,
  factor1,
  factor2,
  factor3,
  factor4,
  factor5,
  subject,
  data,
  formula,
  testing = rep(1, 2^5 - 1),
  nonparametric,
  np.correction
)

Arguments

X

dataframe containing the data in the long table format

alpha

alpha level used for the test

factor1

column name of the data frame X of the first factor variable

factor2

column name of the data frame X of the second factor variable

factor3

column name of the data frame X of the third factor variable

factor4

column name of the data frame X of the fourth factor variable

factor5

column name of the data frame X of the fifth factor variable

subject

column name of the data frame X identifying the subjects

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


hrm.test.dataframe

Description

The function listed below is deprecated and will be defunct in the near future. Please use 'hrm.test' instead.

Usage

hrm.test.dataframe(data, alpha = 0.05, group , subgroup,
factor1, factor2, factor3, subject, response)

Arguments

data

A data.frame containing the data

alpha

alpha level used for the test

subject

column name within the data frame identifying the subjects

group

column name within the data frame specifying the first whole-plot factor

subgroup

column name within the data frame specifying the second whole-plot factor

factor1

column name within the data frame specifying the first sub-plot factor

factor2

column name within the data frame specifying the second sub-plot factor

factor3

column name within the data frame specifying the third sub-plot factor

response

column name within the data frame specifying the measurements

See Also

HRM-deprecated


Test for no main treatment effect, no main time effect, no simple treatment effect and no interaction between treatment and time

Description

Test for no main treatment effect, no main time effect, no simple treatment effect and no interaction between treatment and time

Usage

hrm.test.matrices(data, alpha = 0.05)

Arguments

data

A list containing the data matrices of all groups. The rows are the independent subjects, these observations are assumed to be multivariate normally distributed. The columsn of all matrices need to be in the same order.

alpha

alpha level used for the test

Value

Returns a data frame consisting of the degrees of freedom, the test value, the critical value and the p-value


hrm.test.matrix

Description

The function listed below is deprecated and will be defunct in the near future. Please use 'hrm.test' instead.

Usage

hrm.test.matrix(data, alpha = 0.05)

Arguments

data

A list of matrices

alpha

alpha level used for the test

See Also

HRM-deprecated


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)

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_internal(
  formula,
  data,
  alpha = 0.05,
  subject,
  nonparametric,
  np.correction
)

Arguments

formula

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

data

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

alpha

alpha level used for calculating the critical value for the test

subject

column name within the data frame X identifying the subjects

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.


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") )