imbalance | R Documentation |
Provides a measure of treatment imbalance with respect to a desired ratio of treatments.
imbalance(treatments, treatment.ratios)
treatments |
a factor or a character/numeric vector containing a sequence of treatments. |
treatment.ratios |
a named vector containing the desired treatment ratios. Treatment.ratios should at least contain all unique elements of the treatments vector. |
A treatment vector has imbalance 0 if the treatments occur in the desired ratio. Otherwise, the imbalance is positive.
# A balanced treatment vector
imbalance(factor(c("A","B","B","A"),levels=c("A","B")),treatment.ratios=c(A=1,B=1))
# Still balanced if ratio is given as 50:50 instead of 1:1
imbalance(factor(c("A","B","B","A"),levels=c("A","B")),treatment.ratios=c(A=50,B=50))
# Treatments can also be provided as a numeric vector
imbalance(c(1,2,2,1),treatment.ratios=c("1"=1,"2"=1))
# Treatments can be provided as a character vector
imbalance(c("A","B","B","A"), treatment.ratios=c(A=1,B=1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.