perm_test {FSM} | R Documentation |
Fisher's randomization test for sharp null hypothesis.
Description
Performs Fisher's randomization test for sharp null hypotheses of the form
H_0: c_1 Y_i(1) + c_2 Y_i(2) - \tau = 0
, for a vector of contrasts (c_1, c_2)
.
Usage
perm_test(
Y_obs,
alloc_obs,
alloc,
contrast = c(1, -1),
tau = 0,
method = "marginal mean",
alternative = "not equal"
)
Arguments
Y_obs |
Vector of observed outcome. |
alloc_obs |
Vector of observed treatment assignment. |
alloc |
A matrix of treatment assignments over which the randomization distribution of the test statistic
is computed. Each row of |
contrast |
A vector of the coefficients of the treatment contrast of interest. For example, for estimating the
average treatment effect of treatment 1 versus treatment 2, |
tau |
The value of the treatment contrast specified by the sharp null hypothesis. |
method |
The method of computing the test statistic. If |
alternative |
The type of alternative hypothesis used. For right-sided test, |
Value
A list containing the following items.
test_stat_obs
: The observed value of the test statistic.
test_stat_iter
: A vector of values of the test statistic across repeated randomizations.
p_value
: p-value of the test.
Author(s)
Ambarish Chattopadhyay, Carl N. Morris and Jose R. Zubizarreta.
References
Chattopadhyay, A., Morris, C. N., and Zubizarreta, J. R. (2020), “Randomized and Balanced Allocation
of Units into Treatment Groups Using the Finite Selection Model for R
".
Examples
# Consider N = 12, n1 = n2 = 6.
# We test the sharp null of no treatment effect under CRD.
df_sample = data.frame(index = 1:12, x = c(20,30,40,40,50,60,20,30,40,40,50,60))
# True potential outcomes.
Y_1_true = 100 + (df_sample$x - mean(df_sample$x)) + rnorm(12, 0, 4)
Y_2_true = Y_1_true + 50
# Generate the realized assignment under CRD.
fc = crd(data_frame = df_sample, n_treat = 2, treat_sizes = c(6,6), control = FALSE)
Z_crd_obs = fc$Treat
# Get the observed outcomes
Y_obs = Y_1_true
Y_obs[Z_crd_obs == 2] = Y_2_true[Z_crd_obs == 2]
# Generate 1000 assignments under CRD.
Z_crd_iter = matrix(rep(0, 1000 * 12), nrow = 1000)
for(i in 1:1000)
{
fc = crd(data_frame = df_sample, n_treat = 2, treat_sizes = c(6,6), control = FALSE)
Z_crd_iter[i,] = fc$Treat
}
# Test for the sharp null H0: Y_i(1) = Y_i(0) for all i.
# Alternative: not H0 (two-sided test).
perm = perm_test(Y_obs = Y_obs, alloc_obs = Z_crd_obs, alloc = Z_crd_iter,
contrast = c(1,-1), tau = 0, method = "marginal mean", alternative = 'not equal')
# Obtain the p-value.
perm$p_value