permcluster: Generates a Permuted Data Set

Description Usage Arguments Details Value Author(s) References Examples

Description

This function generates a permuted data set that can be used to perform a permutation test for a variance component for 2-level, 3-level or 4-level data.

Usage

1
permcluster(cluster, data, leveltested)

Arguments

cluster

A vector giving the name of the variables in the data frame data to specify the clustering configuration. The order is important. For 2-level data it is a vector of dimension 1 specifying the level 1 cluster. For 3-level data, it is a vector of dimension 2. The first element specifies the level 1 (outer) cluster and the second one specifies the level 2 (inner) cluster. For 4-level data, it is a vector of dimension 3. The first element specifies the level 1 (outer) cluster, the second one specifies the level 2 (middle) cluster, and the last one specifies the level 3 (inner) cluster.

data

A data frame containing the data.

leveltested

An integer giving the level to be tested. It must be 1 for 2-level data, 1 or 2 for 3-level data, and 1, 2 or 3 for 4-level data. It corresponds to the element in cluster.

Details

This is a utility function that allows to perform a permutation test with another test statistic than the one in the function mvctm.

Value

A data frame that contains the original variables plus 1, 2 or 3 new columns. For 2-level data, a single new column called clusperm1 contains the permuted indices for the level 1 cluster. For 3-level data, two new columns called clusperm1 and clusperm2 contain the permuted indices for the level 1 and level 2 clusters, respectively. For 4-level data, three new columns called clusperm1, clusperm2 and clusperm3 contain the permuted indices for the level 1, level 2, and level 3 clusters, respectively.

Author(s)

Denis Larocque <denis.larocque@hec.ca>

References

Larocque, D., Nevalainen, J. and Oja, H. (2018). Multivariate Variance Components Tests for Multilevel Data. Les Cahiers du GERAD G-2018-58.

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
data(toydata)

# generates a permuted data set with 2-level data

permcluster(cluster=c("classroom"),data=toydata,leveltested=1)

# generates a permuted data set with 4-level data to test for level 2

permcluster(cluster=c("region","school","classroom"),
data=toydata,leveltested=2)

# performing a permutation test with another
# test statistic might look like this

## Not run: 
pval=0
# compute the statistic with the original data. Call in stato.
for (i in 1:npermut)
{
pdata=permcluster(cluster=c("classroom"),data=toydata,leveltested=1)
# compute the statistic with pdata using the new column
# clusperm1 instead of classroom as the cluster index.
# call it statp.
pval=pval+(statp>stato)
}
pval/npermut

## End(Not run)

mvctm documentation built on May 2, 2019, 10:16 a.m.