CausalDataInstrumental
Bases: CausalData
Container for causal inference datasets with causaldata_instrumental variables.
Attributes
- instrument_name (
str) – Column name representing the causaldata_instrumental variable.
Functions
- from_df – Friendly constructor for CausalDataInstrumental.
- get_df – Get a DataFrame with specified columns including instrument.
from_df
Friendly constructor for CausalDataInstrumental.
Parameters
- df (
DataFrame) – The DataFrame containing the data_contracts. - treatment (
str) – Column name representing the treatment variable. - outcome (
str) – Column name representing the outcome variable. - confounders (
Union[str, List[str]]) – Column name(s) representing the confounders/covariates. - user_id (
str) – Column name representing the unique identifier for each observation/user. - instrument (
str) – Column name representing the causaldata_instrumental variable. - **kwargs (
Any) – Additional arguments passed to the Pydantic model constructor.
Returns
CausalDataInstrumental– A validated CausalDataInstrumental instance.
get_df
Get a DataFrame with specified columns including instrument.
Parameters
- columns (
List[str]) – Specific column names to include. - include_treatment (
bool) – Whether to include the treatment column. - include_outcome (
bool) – Whether to include the outcome column. - include_confounders (
bool) – Whether to include confounder columns. - include_user_id (
bool) – Whether to include the user_id column. - include_instrument (
bool) – Whether to include the instrument column.
Returns
DataFrame– A copy of the internal DataFrame with selected columns.
Raises
ValueError– If any specified columns do not exist.
instrument
instrument column as a Series.
Returns
Series– The instrument column.