Skip to contents

Methods to extract the variable names to the elements of the structure of the Design (e.g. treatment, unit of analysis, etc)

Usage

var_table(design, compress = TRUE, report_all = FALSE)

var_names(design, type)

Arguments

design

a Design object

compress

should multiple variables be compressed into a comma-separated string? Default TRUE. If FALSE, multiple columns can be created instead.

report_all

should we report all possible structures even if they don't exist in the Design? Default FALSE.

type

one of "t", "u", "b", "f"; for "treatment", "unit_of_assignment", "block", and "forcing" respectively

Value

var_table() returns the requested table. var_names() returns a vector of variable names.

Details

When compress is TRUE, the result will always have two columns. When FALSE, the result will have number of columns equal to the largest number of variables in a particular role, plus one. E.g., a call such as rct_design(z ~ unitid(a, b, c, d) ... will have 4+1=5 columns in the output matrix with compress = FALSE.

When report_all is TRUE, the matrix is guaranteed to have 3 rows (when the design is an RCT or Obs) or 4 rows (when the design is a RD), with empty variable entries as appropriate. When FALSE, the matrix will have minimum 2 rows (treatment and unit of assignment/unitid/cluster), with additional rows for blocks and forcing if included in the Design.

Examples

des <- rct_design(z ~ uoa(uoa1, uoa2) + block(bid), data = simdata)
var_table(des)
#>      Structure            Variables   
#> [1,] "Treatment"          "z"         
#> [2,] "Unit of Assignment" "uoa1, uoa2"
#> [3,] "Block"              "bid"       
var_table(des, compress = FALSE)
#>      Structure            Variable 1 Variable 2
#> [1,] "Treatment"          "z"        NA        
#> [2,] "Unit of Assignment" "uoa1"     "uoa2"    
#> [3,] "Block"              "bid"      NA        
var_names(des, "t")
#> [1] "z"
var_names(des, "u")
#> [1] "uoa1" "uoa2"
var_names(des, "b")
#> [1] "bid"