Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/get_t_test_matrix_moulton.R
Compares the data obtained for each value of the controlling factor, and constructs a matrix with the t-test results. The tests are corrected for clustering via the Moulton correction
1 | get_t_test_matrix_moulton(treatment_factor, data,cluster_factor, ...)
|
treatment_factor |
Factor indicating the treatment conditions (vector) |
data |
Data obtained under the different conditions (vector of the same length as |
cluster_factor |
Factor describing the clustering. This is a vector of the same length as |
... |
Additional arguments to be passed down to the underlying |
The full list of data should be given, so that standard deviations can be calculated. More precisely, there should be several entries where treatment_factor
has identical values. Care should be taken in the description of the cluster_factor
, namely one should avoid to inadvertently imply clusters across groups if this was not the case in the measurement scheme (see the arguments section); this would in particular happen if one was to restart numbering the clusters in each treatment group, while actually the clusters are truly different experimental conditions.
A matrix containing the p-values of t-tests, comparing the data for each of the possible pairwise combinations of treatment_factor
Thomas Braschler
This is a convenience interface to moulton.t.test, see moulton.t.test for further documentation on the actual testing.
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 32 33 34 35 36 | # First, the indicator variables treatment_factor and cluster_factor.
# Three distinct treatments
treatment_factor = c(rep("T1",20),rep("T2",20),rep("T3",20))
# A total of 12 different clusters, 4 per treatment, each with 5 samples
cluster_factor = c(rep("C1",5),rep("C2",5),rep("C3",5),rep("C4",5),rep("C5",5),rep("C6",5),rep("C7",5),rep("C8",5),rep("C9",5),rep("C10",5),rep("C11",5),rep("C12",5))
# Set the theoretical effects
# Let's have treatment 1 and 2 having no true effect, only treatment 3
effect_treatment_3 = 20
# A fairly large cluster effect
magnitude_cluster_effect=10
# And a fairly small random effect
magnitude_random_effect=3
# Do calculations to obtain the data variable
effect_treatments = rep(0,length(unique(treatment_factor)))
names(effect_treatments)=unique(treatment_factor)
effect_treatments["T3"]=effect_treatment_3
contribution_treatments = effect_treatments[treatment_factor]
effect_cluster=rnorm(length(unique(cluster_factor)),mean=0,sd=magnitude_cluster_effect)
names(effect_cluster)=unique(cluster_factor)
contribution_clusters = effect_cluster[cluster_factor]
contribution_random = rnorm(length(treatment_factor),mean=0,sd=magnitude_random_effect)
data=contribution_random+contribution_clusters+contribution_treatments
names(data)=NULL
get_t_test_matrix_moulton(treatment_factor,data,cluster_factor)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.