AI Prompt Template for Causal Inference and Counterfactual Analysis

Structured prompt design that forces explicit assumptions, causal diagrams, do-calculus steps, and alternative explanations for observational data.

Causal InferenceCounterfactual ReasoningAI Prompt Engineering

Objective: Equip analysts and researchers with a reusable AI prompt that systematically enforces explicit assumption listing, causal diagram construction or do-calculus application, and rigorous evaluation of alternative explanations when working with observational data.

The base prompt was formed through these deliberate design steps:

  • Isolate the three non-negotiable requirements from the use case: list assumptions (especially no unmeasured confounding), apply causal diagrams or do-calculus, and evaluate alternative explanations.
  • Insert explicit instructions that prevent the model from jumping to causal claims without first stating assumptions.
  • Require a visual or textual causal diagram (or formal do-calculus steps) so the reasoning path remains transparent and auditable.
  • Force a dedicated section that surfaces competing non-causal accounts of the same observational pattern.
  • Add modular placeholders so the same prompt skeleton can adapt to different domains, data descriptions, and desired output formats without rewriting the core logic.
  • Keep the language directive and structured so the model produces consistent, reviewable outputs rather than free-form narrative.
Note

The prompt deliberately separates “assumptions” from “methods” so that any hidden confounding or selection bias is surfaced before graphical or algebraic steps begin.

Prompt Template
{{snippet:role_and_context}} You will analyze the following observational data situation: Domain: {{domain}} Data description: {{data_description}} Primary research question: {{research_question}} Outcome variable: {{outcome}} Treatment or exposure variable: {{treatment}} Follow these mandatory steps in order: 1. Explicitly list every causal assumption required for identification. At minimum address: - No unmeasured confounding - Consistency / SUTVA - Positivity - Any domain-specific assumptions For each assumption state why it is plausible or why it may be violated given the data description. 2. Construct a causal diagram (textual DAG description is acceptable) that encodes the assumed relationships among {{treatment}}, {{outcome}}, and relevant covariates. Alternatively, show the do-calculus steps that identify the causal effect of interest. 3. Using the diagram or do-calculus derivation, state the identified estimand and the estimation strategy that follows from it. 4. Evaluate at least three alternative non-causal explanations that could produce the same observational association. Rank them by plausibility and explain what additional data or design would distinguish each alternative from the causal account. 5. Summarize the strength of the causal claim that can be supported and the residual uncertainty that remains. Output format: {{output_format}} Tone: {{tone}}
ElementTypeExample value
{{snippet:role_and_context}}snippetYou are a causal inference specialist who never claims causation from observational data without first listing assumptions and testing alternative explanations.
{{domain}}variablepublic health
{{data_description}}variablelongitudinal claims data linking statin initiation to subsequent cardiovascular events
{{research_question}}variableDoes statin initiation reduce the risk of major adverse cardiovascular events?
{{outcome}}variablemajor adverse cardiovascular events within 3 years
{{treatment}}variablestatin initiation
{{output_format}}variablestructured markdown with numbered sections
{{tone}}variableprecise and cautious
Prompt Example
You are a causal inference specialist who never claims causation from observational data without first listing assumptions and testing alternative explanations. You will analyze the following observational data situation: Domain: public health Data description: longitudinal claims data linking statin initiation to subsequent cardiovascular events Primary research question: Does statin initiation reduce the risk of major adverse cardiovascular events? Outcome variable: major adverse cardiovascular events within 3 years Treatment or exposure variable: statin initiation Follow these mandatory steps in order: 1. Explicitly list every causal assumption required for identification. At minimum address: - No unmeasured confounding - Consistency / SUTVA - Positivity - Any domain-specific assumptions For each assumption state why it is plausible or why it may be violated given the data description. 2. Construct a causal diagram (textual DAG description is acceptable) that encodes the assumed relationships among statin initiation, major adverse cardiovascular events within 3 years, and relevant covariates. Alternatively, show the do-calculus steps that identify the causal effect of interest. 3. Using the diagram or do-calculus derivation, state the identified estimand and the estimation strategy that follows from it. 4. Evaluate at least three alternative non-causal explanations that could produce the same observational association. Rank them by plausibility and explain what additional data or design would distinguish each alternative from the causal account. 5. Summarize the strength of the causal claim that can be supported and the residual uncertainty that remains. Output format: structured markdown with numbered sections Tone: precise and cautious
Tip

When adapting the prompt for a new study, keep the five mandatory steps unchanged and only refresh the domain-specific variables; this preserves the disciplined structure that forces assumption listing and alternative-explanation checks.

Extended example values for each element:

  1. {{snippet:role_and_context}}

    • You are a causal inference specialist who never claims causation from observational data without first listing assumptions and testing alternative explanations.
    • You act as a methodologist focused on transparent identification strategies for observational studies in the social and biomedical sciences.
  2. {{domain}}

    • public health
    • labor economics
    • educational policy evaluation
  3. {{data_description}}

    • longitudinal claims data linking statin initiation to subsequent cardiovascular events
    • administrative records of a job-training program and later earnings
    • school-level test scores before and after a curriculum reform
  4. {{research_question}}

    • Does statin initiation reduce the risk of major adverse cardiovascular events?
    • Does participation in the job-training program increase subsequent earnings?
    • Did the new curriculum raise average student achievement?
  5. {{outcome}}

    • major adverse cardiovascular events within 3 years
    • annual earnings two years after program completion
    • standardized test scores in the following academic year
  6. {{treatment}}

    • statin initiation
    • job-training program enrollment
    • exposure to the new curriculum
  7. {{output_format}}

    • structured markdown with numbered sections
    • concise bullet-point summary followed by a technical appendix
    • table-first presentation of assumptions, diagram, and alternative explanations
  8. {{tone}}

    • precise and cautious
    • formal academic
    • clear and accessible to non-specialist stakeholders
AI Prompt Template for Causal Inference and Counterfactual Analysis