blockclustr: Constructs blocked clusters for blocked and clustered random...

View source: R/blockclustr.R

blockclustrR Documentation

Constructs blocked clusters for blocked and clustered random assignment

Description

Constructs blocked clusters for blocked and clustered random assignment

Usage

blockclustr(
  data,
  id_var,
  block_vars,
  n_tr,
  n_units_per_clust,
  constraint_var = NULL,
  constraint_list = NULL,
  algorithm = "optGreedy",
  distance = "mahalanobis"
)

Arguments

data

A dataframe with units in rows and variables in columns.

id_var

A string specifying which column of data is the units' unique identifier

block_vars

A string or vector of strings specifying which columns of data are the (continuous) blocking covariates.

n_tr

An integer specifying the number of experimental conditions. This is also the number of clusters per block.

n_units_per_clust

An integer specifying the number of units that should be assigned to each cluster. It will not be used if constraint_list is specified.

constraint_var

An optional string specifying which column of data is the variable that cluster composition is constrained by. Must also specify constraint_list.

constraint_list

An optional list of vectors specifying all combinations of constraint_var values that clusters can take. Must also specify constraint_var.

algorithm

A string specifying the algorithm used to construct blockettes. See blockTools::block for more options and information.

distance

A string specifying the distance calculation used when constructing blockettes. See blockTools::block for more options and information.

Value

Returns a list of three elements:

  • design a dataframe containing information about units included in the experimental design

    • id_var the supplied unique identifier

    • block_vars the supplied blocking covariates

    • constraint_var the supplied constraint variable, if applicable

    • block_id an indicator for which block the unit belongs to

    • block_id an indicator for which cluster the unit belongs to

    • block_id a treatment indicator, corresponding with the specified number of conditions, n_tr

  • raw_blockettes is the output of the blockTools::block function, used to construct blockettes

  • unused_units a dataframe containing information about the units in data not included in the experimental design


erossiter/blockclustr documentation built on March 19, 2022, 4:48 a.m.