Skip to content
Submodule
causalis.data_contracts.iv_causal_data

iv_causal_data

Submodule causalis.data_contracts.iv_causal_data with no child pages and 7 documented members.

Classes

Jump directly into the documented classes for this page.

1 items
class
causalis.data_contracts.iv_causal_data.IVCausalData

IVCausalData

Bases: causalis.data_contracts.causaldata.CausalData

Container for instrumental variables causal inference datasets.

Extends :class:CausalData with exactly one instrument column. The stored DataFrame is restricted to outcome, treatment, instrument, confounder, and optional user_id columns.

Attributes

dfpd.DataFrame

DataFrame restricted to the columns used by the IV analysis.

treatment_namestr

Column name representing the endogenous treatment variable.

outcome_namestr

Column name representing the outcome variable.

instruments_namesList[str]

Name of the instrument column, stored as a single-item list.

confounders_namesList[str]

Names of the confounder columns (may be empty).

user_id_namestr, optional

Column name representing the unique identifier for each observation/user.

Initialization

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Canonical target

causalis.data_contracts.iv_causal_data.IVCausalData

Sections

AttributesInitialization
Link to this symbol
attribute
causalis.data_contracts.iv_causal_data.IVCausalData.instruments_names

instruments_names

Value: 'Field(...)'

‘Field(…)’

Canonical target

causalis.data_contracts.iv_causal_data.IVCausalData.instruments_names

Link to this symbol
method
causalis.data_contracts.iv_causal_data.IVCausalData.from_df

from_df

Friendly constructor for IVCausalData.

Parameters

dfpd.DataFrame

The DataFrame containing the data.

treatmentstr

Column name representing the endogenous treatment variable.

outcomestr

Column name representing the outcome variable.

instrumentsUnion[str, List[str]]

Column name(s) representing the instrumental variable(s).

confoundersUnion[str, List[str]], optional

Column name(s) representing the observed confounders/covariates.

user_idstr, optional

Column name representing the unique identifier for each observation/user.

**kwargsAny

Additional arguments passed to the Pydantic model constructor.

Returns

IVCausalData

A validated IVCausalData instance.

Canonical target

causalis.data_contracts.iv_causal_data.IVCausalData.from_df

Sections

ParametersReturns
Link to this symbol
property
causalis.data_contracts.iv_causal_data.IVCausalData.instruments

instruments

List of instrument column names.

Returns

List[str]

Names of the instrument columns.

Canonical target

causalis.data_contracts.iv_causal_data.IVCausalData.instruments

Sections

Returns
Link to this symbol
property
causalis.data_contracts.iv_causal_data.IVCausalData.Z

Z

Design matrix of instruments.

Returns

pd.DataFrame

The DataFrame containing only instrument columns.

Canonical target

causalis.data_contracts.iv_causal_data.IVCausalData.Z

Sections

Returns
Link to this symbol
method
causalis.data_contracts.iv_causal_data.IVCausalData.get_df

get_df

Get a DataFrame with specified columns.

Parameters

columnsList[str], optional

Specific column names to include.

include_treatmentbool, default True

Whether to include the treatment column.

include_outcomebool, default True

Whether to include the outcome column.

include_confoundersbool, default True

Whether to include confounder columns.

include_user_idbool, default False

Whether to include the user_id column.

include_instrumentsbool, default True

Whether to include instrument columns.

Returns

pd.DataFrame

A copy of the internal DataFrame with selected columns.

Raises

ValueError

If any specified columns do not exist.

Canonical target

causalis.data_contracts.iv_causal_data.IVCausalData.get_df

Sections

ParametersReturnsRaises
Link to this symbol
method
causalis.data_contracts.iv_causal_data.IVCausalData.__repr__

__repr__

Canonical target

causalis.data_contracts.iv_causal_data.IVCausalData.__repr__

Link to this symbol