Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • New on SSC: causalspline — nonlinear causal dose–response estimation

    Dear Statalist users,

    I am pleased to announce causalspline, now available from SSC.

    The command estimates causal dose–response functions for continuous treatments under unconfoundedness, using restricted cubic splines to flexibly capture nonlinear relationships (e.g., thresholds, diminishing returns, nonmonotonic patterns).

    It implements three approaches:
    • IPW (generalized propensity score)
    • G-computation
    • Doubly robust estimation
    Postestimation tools include derivatives (marginal effects and curvature), overlap diagnostics, and region-specific summaries of the response function.

    Installation
    ssc install causalspline

    Example
    cs_simulate 500, dgp(threshold) clear
    causalspline, outcome(Y) treatment(T) confounders(X1 X2 X3) method(dr)
    cs_plot

    The command is implemented as an r-class routine.

    More details:
    https://EconPapers.repec.org/RePEc:boc:bocode:s459644

    Comments welcome.

    Kind regards,
    Subir Hait
    Michigan State University

  • #2
    This sounds very interesting, thanks a lot for sharing! I have a few comments and questions.
    • Some input checks could be added. I accidentally entered the dependent variable both under treatment and outcome and was wondering about the strange results... a warning or error message could be added
    • Currently, the program sets the seed internally within Mata, so results are always identical. Given that the SEs depend on randomness, this is rather uncommon. You should pull the rseed into the options so users can have deterministic result yet also test how much the results depend on randomness.
    • Do you have any advice for users working with imputed data?
    • What about adding a by() option so that two (or more) groups can be compared? This sounds like an interesting option for interaction insights.
    • Factor variable notation should be allowed for confounders
    • Do you think it is feasible to allow (sampling) weights?
    • Assuming that the general relationship between outcome and treatment is rather linear, could it make sense to reduce the multiple treatment effects into a single (like the average causal effect over the entire range of the treatment scale)?
    • I think the command is rather powerful and offers a lot of insight. A working paper (or SJ paper) might be beneficial to explain in more detail how the approach works and how to make the most out of it.
    Last edited by Felix Bittmann; 20 Mar 2026, 01:36.
    Best wishes

    Stata 18.0 MP | ORCID | Google Scholar

    Comment


    • #3
      Dear Felix,

      Thank you for the thoughtful comments — very helpful for improving the package.

      A brief response to each point:
      1. Input validation: a check preventing duplicate outcome/treatment variables will be added.
      2. Seed: you are right — a seed() option will be exposed in the next release. (Currently available in cs_simulate, but not yet in causalspline.)
      3. Imputed data: no native mi support yet. The current workaround is to run causalspline on each imputed dataset (e.g., via savecurve()) and combine estimates using Rubin’s rules.
      4. by() option: a useful extension — added to the roadmap.
      5. Factor variables: confounders() currently takes a varlist; factor-variable syntax is not yet supported.
      6. Sampling weights: not yet implemented; feasibility (especially with bootstrap) is under review.
      7. Scalar summary: a single summary effect over the treatment range is planned.
      8. Working paper: agreed — this is on my list.
      Kind regards,
      Subir Hait
      Michigan State University

      Comment

      Working...
      X