Learn R Programming

DeepLearningCausal (version 0.0.107)

conformal_plot: conformal_plot

Description

Visualizes the distribution of estimated individual treatment effects (ITEs) along with their corresponding conformal prediction intervals. The function randomly samples a proportion of observations from a fitted metalearner_ensemble or metalearner_deeplearning object and plots the conformal intervals as vertical ranges around the point estimates. This allows users to visually assess the uncertainty and variation in estimated treatment effects.

Usage

conformal_plot(
  x,
  ...,
  seed = 1234,
  prop = 0.3,
  binary.outcome = FALSE,
  x.labels = TRUE,
  x.title = "Observations",
  color = "steelblue",
  break.by = 0.5
)

Value

A ggplot object showing sampled individual treatment effects with their weighted conformal prediction intervals.

Arguments

x

A fitted model object of class metalearner_ensemble or metalearner_deeplearning that contains a conformal_interval element.

...

Additional arguments (currently unused).

seed

Random seed for reproductibility of subsampling. Default is 1234.

prop

Proportion of observations to randomly sample for plotting. Must be between 0 and 1. Default is 0.3.

binary.outcome

Logical; if TRUE, constrains the y-axis to [-1, 1] for binary outcomes. Default is FALSE.

x.labels

Logical; if TRUE, displays x-axis labels for each sampled observation. Default is TRUE.

x.title

Character string specifying the x-axis title. Default is "Observations".

color

Color of the conformal intervals and points. Default is "steelblue".

break.by

Numeric value determining the spacing between y-axis breaks. Default is 0.5.

Details

The function extracts the estimated ITEs (CATEs) and conformal intervals (ITE_lower, ITE_upper) from the model output, samples a subset of rows, and generates a ggplot2 visualization. Each vertical line represents the conformal prediction interval for one observation’s treatment effect estimate. The conformal intervals are typically obtained from weighted split-conformal inference, using propensity overlap weights to adjust interval width.