| aib_build | R Documentation |
Constructs the core 'aibias' S3 object from a panel dataset. Validates the panel structure and prepares internal data for downstream analysis.
aib_build(
data,
id,
time,
group,
decision,
outcome = NULL,
verbose = TRUE,
schedule = NULL
)
data |
A data frame in long (panel) format. |
id |
Character. Name of the unit identifier column. |
time |
Character. Name of the time/wave column (integer or factor). |
group |
Character. Name of the protected group column. |
decision |
Character. Name of the binary decision column. Numeric 0/1, logical, or character/factor with values "0"/"1" or "TRUE"/"FALSE" (any case); 'NA' marks a present unit without a recorded decision. Any other value is an error. |
outcome |
Character or NULL. Optional downstream outcome column. |
verbose |
Logical. Print validation messages. Default TRUE. |
schedule |
Optional vector of all scheduled occasions, in order. Use it when an occasion may be absent from 'data' altogether, so that the occasions on either side are not treated as consecutive. If NULL, the levels of 'time' are used when it is a factor (including unused levels), otherwise its sorted unique values. Every value of 'time' must appear in the schedule. |
The function expects a balanced or unbalanced panel where: - 'id' indexes units observed over multiple periods - 'time' is an ordered index, mapped to its position in the schedule - 'group' is a categorical variable indicating protected group membership - 'decision' is a binary 0/1 variable (1 = favorable decision)
Each unit may have at most one row per occasion. A row whose decision is 'NA' marks a unit that was present (for example, eligible or enrolled) at that occasion but has no recorded decision. [AIBias::aib_decompose()] reports such units separately from units with no row at all.
Group membership is taken from ‘group' at each row. If a unit’s group changes over time, 'aib_build()' warns; trajectory and transition summaries can still be computed, but [AIBias::aib_decompose()] and [AIBias::aib_bootstrap()] stop, because both follow units over time and need one group per unit.
An object of class '"aibias"'.
data(lending_panel)
obj <- aib_build(lending_panel,
id = "applicant_id",
time = "year",
group = "race",
decision = "approved")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.