assign.next.treatment | R Documentation |
This function assigns the next treatment of a patient, given the previous treatments.
assign.next.treatment(patient.data, treatment.ratios,
previous.treatments = character(0), p = 0.3)
patient.data |
a data frame containing the strata for each patient. The last row of this data frame is assumed to contain the strata for the new patient, who will receive the next treatment. Strata can be given as a factor, or as columns that can be interpreted as a factor. |
treatment.ratios |
a named vector containing the desired ratios in which treatments are to be given. |
previous.treatments |
a factor or numeric/character vector containing the previous treatments. 'previous.treatments' should have an element for each row in patient.data except the last (which represents the current patient for whom no treatment has been determined yet). |
p |
probability with which a random treatment will be chosen (with the desired ratio) instead of choosing the treatment that minimizes imbalance. |
# Define patient data
d <- data.frame( F1=factor(c(1,2,2),levels=1:2),
F2=factor(c(1,1,2),levels=1:2) )
# Define previous treatments
tr <- factor( c("A","A"), levels=c("A","B") )
# Call function to obtain next treatment
next.tr <- assign.next.treatment( d, c(A=2,B=1), tr )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.