<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Neha Aggarwal on Medium]]></title>
        <description><![CDATA[Stories by Neha Aggarwal on Medium]]></description>
        <link>https://medium.com/@neha.aggarwal1003?source=rss-8affbfa6082e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9jPnTkj_Jpq0KXbfaOXhLQ.jpeg</url>
            <title>Stories by Neha Aggarwal on Medium</title>
            <link>https://medium.com/@neha.aggarwal1003?source=rss-8affbfa6082e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 15:48:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@neha.aggarwal1003/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Measuring the Wage Effect of College: Regression to DML]]></title>
            <link>https://medium.com/@neha.aggarwal1003/does-college-really-boost-your-income-e9ca2e2ba864?source=rss-8affbfa6082e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9ca2e2ba864</guid>
            <category><![CDATA[double-machine-learning]]></category>
            <category><![CDATA[simple-regression]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[propensity-score-matching]]></category>
            <category><![CDATA[causal-inference]]></category>
            <dc:creator><![CDATA[Neha Aggarwal]]></dc:creator>
            <pubDate>Tue, 18 Nov 2025 20:52:10 GMT</pubDate>
            <atom:updated>2025-11-18T20:59:16.309Z</atom:updated>
            <content:encoded><![CDATA[<p>Does earning a college degree <em>cause</em> people to earn more, or do people who attend college already differ in ways that would have led to higher wages regardless?</p><p>This is one of the most famous questions in labor economics but answering it correctly requires more than just comparing wages.</p><p>In this project, I walk through three increasingly sophisticated causal inference methods in Python:</p><ol><li><strong>Multiple Linear Regression (OLS)</strong></li><li><strong>Propensity Score Matching (PSM)</strong></li><li><strong>Double Machine Learning (DML)</strong></li></ol><p>The goal is to estimate the <strong>causal effect of having a college degree</strong> on earnings using the classic <em>Wooldridge (Wage1)</em> dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MU9iaC5IGxsZS0qsj489TA.png" /></figure><h4>Dataset</h4><blockquote><em>I used the </em><strong><em>Wooldridge Wage1 dataset</em></strong><em>, which contains individual wage data along with demographic and work-related covariates.</em></blockquote><ul><li><strong>Treatment (D):</strong> College degree (≥16 years of education)</li></ul><pre>df[&#39;college&#39;] = (df[&#39;educ&#39;] &gt;= 16).astype(int) </pre><ul><li><strong>Outcome (Y):</strong> Log hourly wage</li><li><strong>Covariates:</strong> Confounders that influence both wages and college choice such as work experience, job tenure, gender, race, ethnicity, etc.</li></ul><h4>Step 1: Exploratory Data Analysis</h4><p>Before running any causal method, we do basic EDA to understand the data, detect imbalance, and validate assumptions.</p><p>Key EDA steps we performed:</p><h4>1. Visualized wage distributions</h4><p>College graduates had visibly higher wages → but this is correlation, not causation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*azHlAOh8ZPkPGDIcbKGVqA.png" /><figcaption>Fig 1. Box Plot showing distribution of Log Wage by College status</figcaption></figure><h4>2. Checked covariate imbalance</h4><p>College and non-college individuals differ meaningfully:</p><ul><li>More experience among non-graduates</li><li>Higher proportion of women and minorities among non-graduates</li><li>Married individuals are more likely to be a college graduate</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*Yu9Wq74ajIgRbiQfDcYA5w.png" /><figcaption>Table 1. Means of covariates by College Status</figcaption></figure><h4>3. Inspected correlation structure</h4><ul><li>Wage strongly correlated with education</li><li>Confounders correlated with both education and wage</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*pW5y6ayv-NOPqBtD0HRmqg.png" /><figcaption>Table 2. Correlation Matrix — correlation of log wage and education with other covariates</figcaption></figure><p>This justifies applying robust causal methods.</p><h4>Step 2: OLS Regression</h4><p>We begin with the standard econometric approach:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*ojDf7mp3rMkecKtzrl7PFg.png" /></figure><p>A simple regression gives an initial estimate of the effect of college on wages while controlling for covariates. The regression coefficient suggests that college graduates earn roughly <strong>62.93% more</strong> than non-college graduates.</p><p>However, regression assumes linearity, no omitted variables, and homogeneous treatment effects. To reduce bias, we explore matching and modern causal methods.</p><h4>Step 3: Propensity Score Matching (PSM)</h4><p>Regression <em>adjusts</em> for covariates. <strong>PSM <em>balances</em> them.</strong></p><p>In PSM, we estimate the probability of having a college degree given covariates:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*iEqBMihXndC_6S-pEbn09A.png" /></figure><p>Then match each college graduate to a non-graduate with a similar propensity score.</p><h4>Steps followed:</h4><ol><li>Fit logistic regression to estimate propensity scores</li><li>Visualize score distributions (treated vs control)</li><li>Perform nearest-neighbor matching</li><li>Validate covariate balance using Standardized Mean Differences (SMD)</li><li>Estimate treatment effect on matched samples</li></ol><p>After matching individuals using PSM, the average treatment effect on log wages is 64.22<strong>%</strong>, slightly higher than OLS, indicating that part of the raw wage gap is due to differences in experience, tenure, or demographics.</p><h4>Step 4: Double Machine Learning (DML)</h4><p>DML is the most modern and robust method we applied. It uses machine learning models (Random Forests) to flexibly estimate:</p><p>Outcome model: E[Y | X]</p><p>Treatment model: E[D | X]</p><p>Then removes (orthogonalizes) the effects of X from both Y and D before estimating the causal effect.</p><h3>Steps we followed:</h3><ol><li>Created DoubleMLData structure with treatment, outcome, covariates</li><li>Defined ML learners</li></ol><ul><li>RandomForestRegressor for g (outcome)</li><li>RandomForestClassifier for m (treatment)</li><li>RandomForestRegressor for l (nuisance model)</li></ul><p>3. Trained multiple folds with cross-fitting</p><p>4. Extracted the orthogonalized treatment effect</p><p>The estimated wage premium for college graduates is 59.68<strong>%</strong>, reflecting a more accurate causal effect.</p><h4>Key Insights and Conclusion</h4><p>1. College does appear to causally increase earnings — substantially.</p><p>2. Different methods give different estimates:</p><ul><li><strong>OLS</strong> may be biased due to linearity assumptions</li><li><strong>PSM</strong> offers cleaner comparisons but relies on correct propensity score modeling</li><li><strong>DML</strong> provides the most flexible and robust estimate</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9ca2e2ba864" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond A/B Testing: Using Instrumental Variables to Uncover Causal Effects]]></title>
            <link>https://medium.com/@neha.aggarwal1003/beyond-a-b-testing-using-instrumental-variables-to-uncover-causal-effects-0fe850b7ec8b?source=rss-8affbfa6082e------2</link>
            <guid isPermaLink="false">https://medium.com/p/0fe850b7ec8b</guid>
            <category><![CDATA[experimentation]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[ab-testing]]></category>
            <category><![CDATA[instrumental-variable]]></category>
            <category><![CDATA[causal-inference]]></category>
            <dc:creator><![CDATA[Neha Aggarwal]]></dc:creator>
            <pubDate>Thu, 04 Sep 2025 15:10:31 GMT</pubDate>
            <atom:updated>2025-09-09T15:40:23.466Z</atom:updated>
            <content:encoded><![CDATA[<p>When we try to measure cause-and-effect relationships in real life, things often get messy. Simple regression methods like <strong>Ordinary Least Squares (OLS)</strong> work well only when the explanatory variables (X) are unrelated to hidden factors. But in the real world, this assumption breaks down all the time. <strong>Instrumental Variables (IV) </strong>estimation is a powerful technique to address these challenges and it can be applied to real-world experiments, from education to digital marketing.</p><h3>Why OLS Sometimes Fails</h3><p>OLS assumes that variables we use to predict outcomes aren’t influenced by hidden factors. But problems arise when we have:</p><ol><li><strong>Omitted Variables:</strong> <br>- Sometimes an important variable affects both <strong>X</strong> and <strong>Y</strong> but is <strong>unobserved</strong> (not in the data).<br>- Because it’s missing, our model incorrectly attributes its effect to the variables we do have, creating bias.</li><li><strong>Measurement Error:</strong> <br>- If the variable <strong>X</strong> is measured incorrectly (e.g., data entry errors, imperfect surveys), the relationship we estimate between <strong>X</strong> and <strong>Y</strong> will be wrong.</li><li><strong>Simultaneous Causality:</strong> <br>- Sometimes <strong>X</strong> affects <strong>Y</strong>, but <strong>Y</strong> also affects <strong>X</strong> at the same time.<br>- This “two-way” relationship makes it hard to figure out the true direction of cause and effect.</li></ol><p>In case of experiments, even when they are randomized, not every participant follows their assignment. Some customers might not open a promotional email, some students might skip a lesson, some patients might not take the medication they were assigned. In such cases, comparing treatment and control groups directly may <strong>understate or misrepresent the true effect</strong> of the intervention.</p><h3>Example: Email Campaign Experiment</h3><p>Imagine an e-commerce company testing whether a <strong>promotional email</strong> increases product purchases.</p><ul><li><strong>Treatment: </strong>50% of customers are randomly assigned to receive the email.</li><li><strong>Control: </strong>50% are assigned not to receive it.</li></ul><p><strong>Goal:</strong> Measure the effect of the campaign (treatment) on customer purchases (outcome).</p><p><strong>Problem:</strong> Not everyone who is sent the email actually opens or reads it. Those who do open it may be systematically different — for example, more engaged customers who are already more likely to purchase. If we simply compare openers vs. non-openers, the estimate will be biased because <strong>motivation </strong>(an unobserved trait) influences both opening the email and making a purchase.</p><p>When these problems exist, OLS cannot be trusted. We need a method that isolates the <strong>true causal effect</strong>. We will see below how IV helps with addressing this problem.</p><h3>How Instrumental Variables Work</h3><p>IV uses an <strong>instrument (Z)</strong> to isolate variation in treatment (X) that is independent of confounders. The instrument must:</p><ol><li>Be strongly correlated with the treatment (relevance).</li><li>Affect the outcome only through the treatment (exclusion restriction).</li></ol><p>This “clean” variation allows us to estimate the causal effect of X on Y, even with imperfect compliance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P89dorrs2G8EoLkIIRX8bg.png" /><figcaption>Figure 1. Using Instrumental Variable to find true Causal Effect of Treatment (X) on Outcome (Y)</figcaption></figure><h3>Average Treatment Effect (ATE), LATE, and CACE — Explained with Emails</h3><p><strong>ATE (Average Treatment Effect)</strong></p><ul><li>Definition: The average causal effect if everyone received the treatment.</li><li>Example: If all customers received a promotional email, ATE answers: <em>“On average, how much would purchase rates increase?”</em></li></ul><p><strong>LATE (Local Average Treatment Effect)</strong></p><ul><li>Definition: The causal effect for <strong>compliers</strong> — those whose treatment status changes due to the assignment.</li><li>Example: Only some customers actually open the email when it’s sent. LATE measures the effect <strong>for those who opened it because they were assigned to receive it</strong>.</li></ul><p><strong>CACE (Complier Average Causal Effect)</strong></p><ul><li>Essentially the same as LATE in experimental contexts.</li><li>Focuses on the causal effect specifically for compliers.</li></ul><h3>Applying IV in Practice: Email Campaign Experiment</h3><p><strong>Instrument:</strong> Random assignment to treatment (being sent the email) can serve as an instrument for actual exposure (whether the email is opened and read).</p><h3>Step 1: Identify the Instrument</h3><ul><li><strong>Z = Assignment to receive the email</strong> (randomized)</li><li><strong>X = Actual email opened</strong> (treatment)</li><li><strong>Y = Purchase outcome</strong></li></ul><h3>Step 2: Track Assignment, Treatment, and Outcome</h3><figure><img alt="A table showing the example data for email campaign scenario. It has one hot encoded data in 3 columns — Assigned Email (Z), Opened Email (X) and Purchase (Y)" src="https://cdn-images-1.medium.com/max/456/1*rrIr04OjgzR7s5UR83-_Qw.png" /><figcaption>Table 1. Observed Data for the Email Campaign Experiment</figcaption></figure><h3>Step 3: Compute the Differences</h3><p><strong>First Stage — How assignment affects treatment:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*-mRyPRLmaSlybG8SwpEetQ.png" /><figcaption>Equation 1. Measures the fraction of Compliers</figcaption></figure><p><strong>Reduced Form — How assignment affects outcome:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*UGAjSHfxVWyzyUodG-FhJA.png" /><figcaption>Equation 2. Measures the effect of assignment on purchase</figcaption></figure><h3>Step 4: Calculate IV / CACE</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*omICb4__og4xC1jb1r5qdA.png" /><figcaption>Equation 3. Measures the effect of assignment on purchase for the customers who opened Email</figcaption></figure><p><strong>Example Numbers:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*q4NiwTxXcoQlyZLTCAj7NQ.png" /><figcaption>Table 2. Experimental Data showcasing the Purchase Rate and Email Open Rate</figcaption></figure><p>Interpretation: For customers who opened the email <strong>because they were assigned</strong>, purchase probability increases by <strong>2.5 percentage points</strong>.</p><h3>Step 5: Verify IV Assumptions</h3><ul><li><strong>Relevance:</strong> Assignment affects email opens.</li><li><strong>Exclusion Restriction:</strong> Assignment affects purchase only via email exposure.</li><li><strong>Randomness:</strong> Check baseline characteristics for balance.</li><li><strong>Monotonicity:</strong> No customers avoid the email because it was sent (no defiers).</li></ul><h3>Final Thoughts</h3><p>Real-world experiments are messy, not everyone follows their assignment. If we only compare treatment and control, we risk understating the true effect.</p><p>Instrumental Variables fix this by zooming in on the <strong>compliers, </strong>the people whose behavior actually changed because of the intervention. That makes IV more than a statistical trick, it’s a way to turn imperfect experiments into actionable insights.</p><p>In short, IV helps us get past averages and see the <em>real causal impact</em> hidden in the data.</p><h3>Further Reading</h3><ul><li>Angrist, J. D., &amp; Pischke, J. S. (2009). <em>Mostly Harmless Econometrics: An Empiricist’s Companion</em>. Princeton University Press.</li><li>Angrist, J. D., Imbens, G. W., &amp; Rubin, D. B. (1996). Identification of Causal Effects Using Instrumental Variables. <em>Journal of the American Statistical Association</em>, 91(434), 444–455.</li><li>Hernán, M. A., &amp; Robins, J. M. (2020). <em>Causal Inference: What If</em>. Chapman &amp; Hall/CRC. Free online version.</li><li>Imbens, G. W., &amp; Angrist, J. D. (1994). Identification and Estimation of Local Average Treatment Effects. <em>Econometrica</em>, 62(2), 467–475.</li><li>A nice blog-style overview: Causal Inference for the Brave and True.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0fe850b7ec8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>