View source: R/groupRAR_functions.R
| CRDesign | R Documentation |
Simulating complete randomization with two-sided hypothesis testing in a clinical trial context.
CRDesign(k, p, ssn, nsim = 2000, alpha = 0.05, test.fun = NULL, typeI = FALSE,
seed = NULL)
k |
A positive integer. The number of treatment groups in the trial ( |
p |
A vector of length |
ssn |
A positive integer. The total number of participants in each simulated trial. |
nsim |
A positive integer. The number of simulated trials, with a default value of 2000. |
alpha |
A number between 0 and 1. The significance level of the two-sided test, with a default value of 0.05. |
test.fun |
An optional function |
typeI |
Logical. If |
seed |
An optional integer passed to |
Complete randomization assigns each participant to one of the treatment groups with equal probability, independently of all other participants.
An object of class "grouprar", a list that is printed as a short summary (see print.grouprar), with the following elements.
method |
The name of the procedure. |
sample size |
The total sample size. |
parameter |
The true success rates used in the simulations, named |
propotion |
The mean allocation proportion of each arm over the simulations, named |
sd of propotion |
The standard deviation of the allocation proportion of each arm over the simulations. |
failure rate |
The mean failure rate over the simulations. |
sd of failure rate |
The standard deviation of the failure rate (or mean response) over the simulations. |
power |
The proportion of simulated trials that reject the null hypothesis of equal success rates. Simulations in which the test cannot be computed are dropped. |
data: failureRate |
The failure rate (or mean response) of each simulated trial. |
data: test |
The test decision of each simulated trial (1 = reject). |
data: assignment |
The treatment assignments of the last simulated trial. |
data: propotion |
A data frame with the allocation proportions of each simulated trial. |
data: allocation |
An |
type I error |
Only if |
## a simple use
CR.res <- CRDesign(k = 3, p = c(0.7, 0.8, 0.6), ssn = 400, nsim = 100)
## view the output
CR.res
## view all simulation settings
CR.res[["method"]]
CR.res[["parameter"]]
## view the simulation results
CR.res[["propotion"]]
CR.res[["failure rate"]]
CR.res[["power"]]
CR.res[["data: assignment"]]
## estimate the type I error as well, with a reproducible seed
res <- CRDesign(k = 2, p = c(0.6, 0.8), ssn = 100, nsim = 50, typeI = TRUE, seed = 1)
summary(res)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.