View source: R/create_null_rand.R
create_null_rand | R Documentation |
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
)
y |
Vector of observed outcomes |
w |
Vector indicating treatment assignments |
rand_matrix |
Matrix with permutations for experiment assignments |
test_stat |
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). |
fun |
Test statistic function (optional). |
alternative |
Character string specifying alternative hypothesis. Must be one of "two-sided" (default), "greater", or "less". |
bw |
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).
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
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.