create_null_rand {Counternull} | R Documentation |
Create Null Randomization Distribution
Description
Generates null randomization distribution for a given test statistic.
Usage
create_null_rand(
y,
w,
rand_matrix,
test_stat = NULL,
fun = NULL,
alternative = NULL,
bw = NULL
)
Arguments
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) |
Details
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).
Value
Class "null_rand" with 11 entries:
- null_dist
Vector of permuted test statistics under the null hypothesis
- t_obs
Observed test statistic
- counts
Number of test statistics more extreme than observed test statistic
- pvalue
Fisher-Exact P-value
- alternative
Specified alternative
- rand_matrix
Randomization matrix used to generate null distribution
- bin_width
Specified bin width
- y
Observed outcomes
- w
Vector indicating treatment assignments
- test_stat
Name of built in test statistic function
- fun
Test statistic function
Examples
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)