Skip to contents

Fabricating data

The entry point. Everything else is called from inside it.

fabricate()
Fabricate a data frame

Levels

Give the data a shape: units inside clusters, a panel of countries and years, or a second population linked to the first.

add_level()
Add a level, nested in the one before it if there is one
nest_level()
Nest a level in the one before it (same as a later add_level())
declare_level()
Declare an independent level for cross-classification
import_level()
Import an existing data frame as a level
cross_levels()
Create a full Cartesian product of declared levels
link_levels()
Sample N rows from a Cartesian product with optional correlation
modify_level()
Modify columns of an existing level, or of the rows in hand

Potential outcomes

An outcome under each condition, and the one a unit actually shows.

potential_outcomes()
Build potential outcomes columns
reveal_outcomes()
Reveal observed outcomes from potential outcomes columns

Drawing discrete variables

Turn a latent variable into the kind of measurement a survey returns.

draw_binary()
Draw binary (0/1) outcomes
draw_binomial()
Draw binomial counts
draw_count()
Draw Poisson count data
draw_categorical()
Draw categorical outcomes
draw_ordered()
Draw ordered categorical outcomes from a latent variable
draw_likert()
Recode a latent variable into a Likert response
split_quantile()
Split data into quantile buckets
draw_quantile()
Draw quantile bucket assignments

Drawing clustered variables

Draws with a target intra-cluster correlation, or serial correlation within a unit over time.

draw_normal_icc()
Draw normally distributed data with a target intra-cluster correlation
draw_binary_icc()
Draw binary data with a target intra-cluster correlation
draw_normal_ar()
Draw normally distributed data with serial correlation within clusters

Drawing correlated variables

Several variables at once, or one correlated with a variable you have.

draw_multivariate()
Draw multivariate random variables
correlate()
Generate a variable correlated with an existing variable

Resampling

Bootstrap a data frame, respecting the levels it was built with.

resample_data()
Resample a data frame, with optional hierarchical cluster resampling
ALL
Keep every unit at a resampling level

Calling fabricatr from a package

For a caller that captures the expressions itself, as DeclareDesign’s declaration verbs do.

fabricate_with_dots()
Fabricate from a list of quosures

fabricatr 1.x spellings

Kept so that scripts written for fabricatr 1.x run unchanged. Each is accepted and warns once with the call to write instead.

join_using()
Name the levels to cross or link
recycle()
Recycle a vector to the length of the level being built