Description Usage Arguments Examples
View source: R/discRD-local-random.r
Mean difference test (t-test) for local random approach
1 | local_random_test_int(basemod, data, bootse, bootp)
|
basemod |
baseline formula. |
data |
data.frame which you want to use. |
bootse |
numeric. Generate N averages of bootstrap samples and use the standard deviation as the standard error of the average. If missing, standard error of mean is calculated by sqrt(v / e) where v is unbiased variance of outcome, and e is effective sample size: e = sum(w) ^ 2 / sum(w ^ 2). If w is missing, we set w = 1, and obtain e = 1 / n. standard error of mean difference is obtained by sqrt((v1 / e1) + (v0 / e0)) |
bootp |
numeric. Perform a permutation test with N re-randomizations. The p-value is obtained at a rate where the absolute value of the mean difference due to rerandomization is greater than the absolute value of the observed mean difference. If missing, standard t-test is performed. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## Not run:
running <- sample(1:100, size = 1000, replace = TRUE)
cov1 <- rnorm(1000, sd = 2); cov2 <- rnorm(1000, mean = -1)
y0 <- running + cov1 + cov2 + rnorm(1000, sd = 10)
y1 <- 2 + 1.5 * running + cov1 + cov2 + rnorm(1000, sd = 10)
y <- ifelse(running <= 50, y1, y0)
bin <- ifelse(y > mean(y), 1, 0)
w <- sample(c(1, 0.5), size = 1000, replace = TRUE)
raw <- data.frame(y, bin, running, cov1, cov2, w)
set_optDiscRD(discRD.cutoff = 50, discRD.assign = "smaller")
useit <- clean_rd_data(y ~ running, data = raw)
str(local_random_test_int(y ~ running, useit$data))
str(local_random_test_int(y ~ running, useit$data, bootse = 100))
str(local_random_test_int(y ~ running, useit$data, bootp = 100))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.