Generates null randomization distribution for a given test statistic.
create_null_rand(
y,
w,
rand_matrix,
test_stat = NULL,
fun = NULL,
alternative = NULL,
bw = NULL
)Class "null_rand" with 11 entries:
Vector of permuted test statistics under the null hypothesis
Observed test statistic
Number of test statistics more extreme than observed test statistic
Fisher-Exact P-value
Specified alternative
Randomization matrix used to generate null distribution
Specified bin width
Observed outcomes
Vector indicating treatment assignments
Name of built in test statistic function
Test statistic function
Vector of observed outcomes
Vector indicating treatment assignments
Matrix with permutations for experiment assignments
Name of built in test statistic function. Provide "diffmeans" for difference of means, "t" for t test, "paired-t" for paired t test, and "cohens-d" for cohen's d test (optional).
Test statistic function (optional).
Character string specifying alternative hypothesis. Must be one of "two-sided" (default), "greater", or "less".
Bin width for histogram (optional)
Call summary on "null_rand" class to retrieve information on the null randomization distribution. Call plot on "null_rand" class for visualization of null randomization distribution.
Assignments must be indicated in arguments "w" and "rand_matrix" using numeric 1 or 0.
Argument "rand_matrix" must have assignment permutations in each column and must have the same number of rows as there are entries in "w".
One of either argument "test_stat" or "fun" must be specified.
Argument "fun" must take in two parameters (treated outcomes and control outcomes) and returns a numeric test statistic value (scalar).
y = sample_data$turn_angle
w = sample_data$w
n_r = create_null_rand(y, w, sample_matrix, test_stat = c("t"))
summary(n_r)
plot(n_r)
Run the code above in your browser using DataLab