Learn R Programming

blockTools

R package for Design of Randomized Experiments

blockTools blocks units into experimental blocks with one unit per treatment condition by creating a measure of multivariate distance between all possible pairs of units. Users can set the maximum, minimum, or an allowable range of differences between units on one variable. blockTools also randomly assigns units to treatment conditions, and can diagnose potential interference between units assigned to different treatment conditions. Users can write outputs to .tex and .csv files.

Examples

After installation (see below), at the R prompt:

library(blockTools)

# load the example data: 
data(x100) 

# create blocked pairs:
out <- block(x100, id.vars = "id", block.vars = c("b1", "b2")) 

# assign one member of each pair to treatment/control:
assg <- assignment(out) 

# detect unit pairs with different treatment assignments 
#   that are within 1 unit of each other on variable "b1":
diag <- diagnose(assg, x100, id.vars = "id", suspect.var = "b1", suspect.range = c(0, 1)) 

To view the results:

# The blocked pairs:
out$blocks 

# The assigned pairs:
assg

# Those pairs with small distances on "b1" between them:
diag

Installation

Install blockTools with

install.packages("blockTools")

If you have access to the private repository, this package can be installed via

devtools::install_github("ryantmoore/blockTools", 
                         auth_token = "<your PAT for this private repo>")

Copy Link

Version

Install

install.packages('blockTools')

Monthly Downloads

529

Version

0.6.6

License

GPL (>= 2) | file LICENSE

Maintainer

Ryan T Moore

Last Published

January 22nd, 2025

Functions in blockTools (0.6.6)

outTeX

Export blocked or assigned data to .tex format files
x100

Simulated data for demonstrating blockTools functionality
seqblock

Sequential assignment of unit(s) into experimental conditions using covariates
assignment

Randomly assign blocked units to treatment conditions
extract_conditions

Create vector of integers containing treatment condition identifiers
createBlockIDs

Create vector of integers containing block identifiers
diagnose

Diagnose whether units assigned to different treatment conditions may be subject to interference or pairwise imbalance
assg2xBalance

Calculate balance statistics from an assignment object
blockTools-package

Block, Randomly Assign, and Diagnose Potential Interference in Randomized Experiments
invertRIconfInt

Calculate treatment effect confidence intervals by inverting the randomization test
block2seqblock

Prepare prior nonsequential assignments for subsequent sequential assignments
block

Block units into homogeneous experimental blocks
outCSV

Export blocked or assigned data to .csv format files