Last data update: 2014.03.03

R: Test for main effects and interaction effects of one or two...
hrm.test.2R Documentation

Test for main effects and interaction effects of one or two between-subject factors and one or two within-subject factors

Description

Test for main effects and interaction effects of one or two between-subject factors and one or two within-subject factors

Usage

hrm.test.2(X, alpha = 0.05, group, subgroup, factor1, factor2, subject, data)

Arguments

X

list containing the data matrices of all groups

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 within-subject factor

factor2

column name of the second within-subject factor crossed with factor1

subject

column name of the data frame X identifying the subjects

data

column name of the data frame X containing the measurement data

Value

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

Examples

n=c(45, 22, 57, 36)
X_1 = mvrnorm(n = n[1], mu = rep(0,40), Sigma = diag(40))
X_2 = mvrnorm(n = n[2], mu = rep(0,40), Sigma = diag(40))
X_3 = mvrnorm(n = n[3], mu = rep(0,40), Sigma = diag(40))
X_4 = mvrnorm(n = n[4], mu = rep(0,40), Sigma = diag(40))

X_1 = c(t(as.matrix(X_1)))
X_1 = data.frame(group = "SCC+", value = X_1)

X_2 = c(t(as.matrix(X_2)))
X_2 = data.frame(group= "SCC-", value = X_2)


X_3 = c(t(as.matrix(X_3)))
X_3 = data.frame(group = "MCI", value = X_3)


X_4 = c(t(as.matrix(X_4)))
X_4 = data.frame(group = "AD", value = X_4)

X = rbind(X_1, X_2, X_3, X_4)
X$subject = gl(160, 40)
X$variable = as.factor(rep(gl(4, 10),160))
X$region = as.factor(rep(rep(1:10,4),160))
X$subgroup = as.factor(rep(gl(2, 40),80))
X$group = as.factor(X$group)

hrm.test.2(X,0.05,group="group",factor1="variable",
factor2="region",subject="subject",data="value")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(HRM)
Loading required package: MASS
Loading required package: matrixcalc
Loading required package: plyr
Loading required package: ggplot2
Loading required package: reshape2
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HRM/hrm.test.2.Rd_%03d_medium.png", width=480, height=480)
> ### Name: hrm.test.2
> ### Title: Test for main effects and interaction effects of one or two
> ###   between-subject factors and one or two within-subject factors
> ### Aliases: hrm.test.2
> 
> ### ** Examples
> 
> n=c(45, 22, 57, 36)
> X_1 = mvrnorm(n = n[1], mu = rep(0,40), Sigma = diag(40))
> X_2 = mvrnorm(n = n[2], mu = rep(0,40), Sigma = diag(40))
> X_3 = mvrnorm(n = n[3], mu = rep(0,40), Sigma = diag(40))
> X_4 = mvrnorm(n = n[4], mu = rep(0,40), Sigma = diag(40))
> 
> X_1 = c(t(as.matrix(X_1)))
> X_1 = data.frame(group = "SCC+", value = X_1)
> 
> X_2 = c(t(as.matrix(X_2)))
> X_2 = data.frame(group= "SCC-", value = X_2)
> 
> 
> X_3 = c(t(as.matrix(X_3)))
> X_3 = data.frame(group = "MCI", value = X_3)
> 
> 
> X_4 = c(t(as.matrix(X_4)))
> X_4 = data.frame(group = "AD", value = X_4)
> 
> X = rbind(X_1, X_2, X_3, X_4)
> X$subject = gl(160, 40)
> X$variable = as.factor(rep(gl(4, 10),160))
> X$region = as.factor(rep(rep(1:10,4),160))
> X$subgroup = as.factor(rep(gl(2, 40),80))
> X$group = as.factor(X$group)
> 
> hrm.test.2(X,0.05,group="group",factor1="variable",
+ factor2="region",subject="subject",data="value")
                 hypothesis       df1       df2     crit      test   p.value
1                     group  2.929272  107.6628 2.709897 0.7245806 0.5363656
2                  variable  3.060963  356.7679 2.612488 0.0980434 0.9630341
3                    region  9.042083  794.1228 1.889419 0.8546222 0.5662852
4          group : variable  9.050656  356.7679 1.903473 1.2810138 0.2453273
5            group : region 24.372561  794.1228 1.526853 0.8127668 0.7248013
6         variable : region 26.594209 2479.8627 1.494137 0.5774369 0.9585325
7 group : variable : region 72.964628 2479.8627 1.292927 1.2121047 0.1088848
  sign.code
1          
2          
3          
4          
5          
6          
7          
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>