hrm_test: Test for Multi-Factor High-Dimensional Repeated Measures

Description Usage Arguments Value Examples

View source: R/S3methods.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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,
  variable = NULL,
  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

variable

if not 'NULL' then multivariate tests are applied. We assume that for each factor level of 'variable', we observe several repated measurements. Currently only supports designs with 1 whole- and one sub-plot factor.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## 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
?EEG

# Univariate Approach
hrm_test(value ~ group*region*variable, subject = "subject", data = EEG)

# Multivariate Approach: testing effects for each variable
hrm_test(value~group*region, subject=subject, variable=variable, data = EEG)

HRM documentation built on Feb. 6, 2020, 5:15 p.m.