Use it when you want to begin causal inference work without writing the first draft from scratch.
Propensity Score Analysis AI Prompt
Implement and evaluate a propensity score analysis to estimate a causal effect from observational data. Treatment variable: {{treatment}} (binary: treated vs untreated) Outcome:... Copy this prompt template, run it in your AI tool, and use related prompts to continue the workflow.
Implement and evaluate a propensity score analysis to estimate a causal effect from observational data.
Treatment variable: {{treatment}} (binary: treated vs untreated)
Outcome: {{outcome}}
Potential confounders: {{confounders}}
Data: {{data_description}}
1. Estimand clarification:
- ATE (Average Treatment Effect): the effect if the entire population were treated vs untreated
- ATT (Average Treatment Effect on the Treated): the effect for those who actually received treatment
- ATC: average effect for the controls if they had been treated
- Choose based on the scientific question; ATT is most common in observational studies
2. Propensity score estimation:
PS = P(Treatment = 1 | X)
- Fit a logistic regression with treatment as the outcome and all confounders as predictors
- Include: all variables that affect the outcome OR that affect both treatment and outcome
- Do NOT include: instrumental variables (variables affecting treatment but NOT outcome)
- Do NOT include: colliders (effects of treatment or outcome)
- Check common support: there should be overlap in PS distributions between treated and controls
Limited overlap = inability to estimate causal effect for some subgroups
3. PS matching:
- Nearest neighbor matching: each treated unit matched to the closest control by PS
- Caliper matching: require |PS_treated - PS_control| < 0.2 x SD(PS) (discard poor matches)
- 1:1 vs 1:k matching: k>1 increases precision but introduces bias if poor matches are forced
- Matching with replacement: allows controls to be reused (reduces bias, increases variance)
4. Balance assessment:
- Standardized mean differences (SMD) before and after matching for each confounder
- SMD < 0.10 after matching: good balance
- Love plot: visualize SMD for each confounder before and after adjustment
- Do NOT use p-values for balance checking — they are affected by sample size, not balance
5. Analysis after matching:
- Estimate the treatment effect using a paired or stratified outcome model
- Use doubly robust estimation: combine PS weighting with outcome regression (consistent if either is correct)
- Report: estimated causal effect, 95% CI (using robust standard errors), and the matched sample size
6. Sensitivity analysis for unmeasured confounding:
- Rosenbaum bounds: how strong would an unmeasured confounder need to be to explain away the result?
- Gamma parameter: if Gamma = 2, the odds of treatment could differ by a factor of 2 for matched pairs with identical observed covariates
- E-value: minimum association a confounder would need with both treatment and outcome to fully explain the observed effect
Return: PS model specification, overlap assessment, balance table (pre/post), causal effect estimate, and sensitivity analysis.When to use this prompt
Use it when you want a more consistent structure for AI output across projects or datasets.
Use it when you want prompt-driven work to turn into a reusable notebook or repeatable workflow later.
Use it when you want a clear next step into adjacent prompts in Causal Inference or the wider Statistician library.
What the AI should return
The AI should return a structured result that covers the main requested outputs, such as Estimand clarification:, ATE (Average Treatment Effect): the effect if the entire population were treated vs untreated, ATT (Average Treatment Effect on the Treated): the effect for those who actually received treatment. The final answer should stay clear, actionable, and easy to review inside a causal inference workflow for statistician work.
How to use this prompt
Open your data context
Load your dataset, notebook, or working environment so the AI can operate on the actual project context.
Copy the prompt text
Use the copy button above and paste the prompt into the AI assistant or prompt input area.
Review the output critically
Check whether the result matches your data, assumptions, and desired format before moving on.
Chain into the next prompt
Once you have the first result, continue deeper with related prompts in Causal Inference.
Frequently asked questions
What does the Propensity Score Analysis prompt do?+
It gives you a structured causal inference starting point for statistician work and helps you move faster without starting from a blank page.
Who is this prompt for?+
It is designed for statistician workflows and marked as intermediate, so it works well as a guided starting point for that level of experience.
What type of prompt is this?+
Propensity Score Analysis is a single prompt. You can copy it as-is, adapt it, or use it as one step inside a larger workflow.
Can I use this outside MLJAR Studio?+
Yes. The prompt text works in other AI tools too, but MLJAR Studio is the best fit when you want local execution, visible Python code, and reusable notebooks.
What should I open next?+
Natural next steps from here are Difference-in-Differences Design, Instrumental Variables Analysis.