Learn R Programming

HRM (version 1.3.0)

hrm_test: 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 list hrm_test(data, alpha = 0.05, ...)

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

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.

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

Examples

Run this code
## 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)

Run the code above in your browser using DataLab