Simulates a randomized treatment based on an urn model.
rud(
n,
alpha = c(1, 1),
beta = 1,
labels = seq(1, length(alpha)),
data.frame = FALSE,
startid = 1
)
A vector with group indices. If the argument data.frame=TRUE
is used then a data frame with three variables is returned: id, group, and treatment (the group label).
the number of individuals to randomize
a non-negative integer vector of weights for each treatment group. The length of the vector corresponds to the number of treatment groups.
a non-negative integer of weights added to the groups that were not given treatment
a vector of treatment labels. Must be the same length as the length of alpha.
A logical that determines if the function should return a vector of group indices (the default, if FALSE) or a data frame (if TRUE).
margin paramaters; vector of length 4 (see par
)
The urn model can be described as follows: For k different treatments, the urn design is initiated with a number of balls in an urn corresponding to the start weight (the alpha argument), where each treatment has a specific colour. Whenever a patient arrives, a random ball is drawn from the urn and the colour decides the treatment for the patient. For each of the treatments that weren't chosen we add beta balls of the corresponding colour(s) to the urn to update the probabilities for the next patient.
rud(5)
rud(5, alpha=c(1,1,10), beta=5)
Run the code above in your browser using DataLab