MyNixOS website logo
Description

Nonlinear Causal Dose-Response Estimation via Splines.

Estimates nonlinear causal dose-response functions for continuous treatments using spline-based methods under standard causal assumptions (unconfoundedness / ignorability). Implements three identification strategies: Inverse Probability Weighting (IPW) via the generalised propensity score (GPS), G-computation (outcome regression), and a doubly-robust combination. Natural cubic splines and B-splines are supported for both the exposure-response curve f(T) and the propensity nuisance model. Pointwise confidence bands are obtained via the sandwich estimator or nonparametric bootstrap. Also provides fragility diagnostics including pointwise curvature-based fragility, uncertainty-normalised fragility, and regional integration over user-defined treatment intervals. Builds on the framework of Hirano and Imbens (2004) <doi:10.1111/j.1468-0262.2004.00481.x> for continuous treatments and extends it to fully nonparametric spline estimation.

CausalSpline

CRAN status R-CMD-check License: GPL v3

Overview

CausalSpline estimates nonlinear causal dose-response functions for continuous treatments using spline-based methods under standard causal assumptions (unconfoundedness + positivity).

Most causal inference tools assume a linear treatment effect:

$$Y = \beta_0 + \beta_1 T + \gamma X + \varepsilon$$

Real policy and health problems often violate this: dosage effects, thresholds, diminishing returns, and non-monotone relationships are common. CausalSpline models the exposure-response curve nonparametrically:

$$E[Y(t)] = \beta_0 + f(T)$$

where $f(T)$ is a natural cubic spline or B-spline, estimated via IPW, G-computation, or doubly-robust methods.


Installation

# CRAN
install.packages("CausalSpline")

# Development version
remotes::install_github("causalfragility-lab/CausalSpline")

Quick Example

library(CausalSpline)

# Simulate data with a threshold effect
set.seed(42)
dat <- simulate_dose_response(n = 500, dgp = "threshold", confounding = 0.6)

# Fit causal dose-response curve via IPW
fit <- causal_spline(
  Y ~ T | X1 + X2 + X3,   # outcome ~ treatment | confounders
  data        = dat,
  method      = "ipw",
  df_exposure = 5
)

summary(fit)
plot(fit)

# G-computation alternative
fit_gc <- causal_spline(Y ~ T | X1 + X2 + X3, data = dat,
                        method = "gcomp", df_exposure = 5)

# Doubly robust estimation
fit_dr <- causal_spline(Y ~ T | X1 + X2 + X3, data = dat,
                        method = "dr", df_exposure = 5)

# Predict at specific treatment values
predict(fit_gc, newt = c(3, 5, 7), se_fit = TRUE)

# Check positivity / overlap
check_overlap(dat$T, fit$weights)

Fragility Diagnostics

A key feature of CausalSpline is geometric fragility diagnostics — tools for evaluating the structural stability of the estimated dose-response curve across treatment levels.

# Slope-based fragility (identifies flat / weak-effect regions)
fc_slope <- fragility_curve(fit, type = "inverse_slope")
plot(fc_slope)

# Curvature-based fragility (identifies thresholds and turning points)
fc_curv <- fragility_curve(fit, type = "curvature_ratio")
plot(fc_curv)

# Regional fragility summary over a policy-relevant interval
region_fragility(fit, a = 3, b = 6, type = "curvature_ratio")

These diagnostics complement traditional sensitivity analyses by examining the internal geometric stability of the causal function — where is the estimated relationship flat, rapidly changing, or structurally ambiguous?


Supported Methods

Methodmethod =Consistent if ...
Inverse Probability Weighting"ipw"GPS model correct
G-computation"gcomp"Outcome model correct
Doubly Robust (AIPW)"dr"At least one model correct

Supported DGPs (for Simulation)

simulate_dose_response(dgp = "threshold")   # flat region then linear rise
simulate_dose_response(dgp = "diminishing") # concave / diminishing returns
simulate_dose_response(dgp = "nonmonotone") # inverted-U / hump shape
simulate_dose_response(dgp = "linear")      # linear baseline
simulate_dose_response(dgp = "sinusoidal")  # oscillatory / complex shape

Key Functions

FunctionDescription
causal_spline()Estimate the causal dose-response curve
fragility_curve()Compute local geometric fragility diagnostics
region_fragility()Regional fragility summary over treatment intervals
gradient_curve()First and second derivatives of the estimated curve
dose_response_curve()Extract the dose-response data frame
predict()Predict E[Y(t)] at new treatment values
check_overlap()Overlap / positivity diagnostics (ESS, weight plot)
simulate_dose_response()Simulate nonlinear dose-response datasets

Relationship to MultiSpline

CausalSpline is the causal extension of MultiSpline. While MultiSpline fits multivariate spline regressions for prediction, CausalSpline:

  • Incorporates the generalised propensity score for causal identification
  • Targets the marginal structural mean $E[Y(t)]$, not the conditional mean
  • Provides doubly-robust estimation
  • Includes positivity diagnostics (ESS, weight trimming)
  • Adds geometric fragility diagnostics with no precedent in existing packages

References

  • Hirano, K., & Imbens, G. W. (2004). The propensity score with continuous treatments. In Applied Bayesian Modeling and Causal Inference from Incomplete-Data Perspectives (pp. 73–84). Wiley.
  • Imbens, G. W. (2000). The role of the propensity score in estimating dose-response functions. Biometrika, 87(3), 706–710.
  • Robins, J. M., Hernán, M. A., & Brumback, B. (2000). Marginal structural models and causal inference in epidemiology. Epidemiology, 11(5), 550–560.
  • Flores, C. A., Flores-Lagunes, A., Gonzalez, A., & Neumann, T. C. (2012). Estimating the effects of length of exposure to instruction in a training program. Review of Economics and Statistics, 94(1), 153–171.

Citation

citation("CausalSpline")

License

GPL (>= 3)

Maintainer: Subir Hait [email protected]
Michigan State University.

Metadata

Version

0.1.0

License

Unknown

Platforms (80)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows