Build a causal data frameSource:
causal_tbl is a tibble with additional attribute information stored
in causal_cols. See the 'Internal structure' for more on the structure of this
causal_tbl(..., .outcome = NULL, .treatment = NULL) new_causal_tbl(..., .outcome = NULL, .treatment = NULL) as_causal_tbl(x) is_causal_tbl(x)
the column containing the outcome variable (tidy-selected). Can be set later with
the column containing the treatment variable (tidy-selected). Can be set later with
A data frame to be checked or coerced
At its core, a
causal_tbl is just a tibble, and it should behave like
a tibble in every meaningful way.
What sets a
causal_tbl apart is that it keeps track of causal columns:
variables or objects which play a particular causal role.
These can be accessed with the various getter and setter functions included
in this package, like
new_causal_tbl(): Construct a
causal_tblwith no checks
as_causal_tbl(): Coerce a data frame to a
TRUEif a data frame is a
The causal_cols attribute is considered mostly internal, and end users
do not have to worry about its internal structure. However, for those
developing packages based off of
causal_tbl, it is useful to understand the
underlying structure of
causal_cols attribute is a named list, with each element corresponding
to a type of causal variable or object:
Each of these elements is a character vector, with each element being a name
of a column in the data frame.
For some variables, this vector should be of length 1, but for other
variables, there may be multiple columns of that type.
So, for example, if a package author was developing methods for causal
inference with multiple continuous treatments, the
causal_cols could have an entry for each treatment column.
names() of the columns within a particular element of
causal_cols convey information on any associated variable. For example,
the treatment variable is by default associated with a particular outcome.
And a propensity score or outcome model is associated with a particular
treatment or outcome variable.
The column names stored within any part of
causal_cols will be automatically
updated if columns are renamed, or set to
NULL if columns are dropped.
This reassignment happens automatically and silently in all cases.
It is the responsibility of implementers of particular methods to check
causal_tbl has the necessary columns set via helpers like