<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>causal-inference-basics on Ray Yang, Ph.D.</title>
    <link>https://yangphd.com/series/causal-inference-basics/</link>
    <description>Recent content in causal-inference-basics on Ray Yang, Ph.D.</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 23 Jun 2021 00:00:00 +0000</lastBuildDate>
    
        <atom:link href="https://yangphd.com/series/causal-inference-basics/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Regression Discontinuity Design</title>
      <link>https://yangphd.com/research/causal_inference_basics/causal-inference-regression-discontinuity-design/</link>
      <pubDate>Wed, 23 Jun 2021 00:00:00 +0000</pubDate>
      
      <guid>https://yangphd.com/research/causal_inference_basics/causal-inference-regression-discontinuity-design/</guid>
      <description>


&lt;div id=&#34;the-causality-graph&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;the Causality Graph&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/8RDD_files/figure-html/unnamed-chunk-1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-the-differences-in-y-not-explained-by-treatment-and-time&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Remove the Differences in Y NOT explained by Treatment and Time&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/8RDD_files/figure-html/unnamed-chunk-2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Difference-in-Difference</title>
      <link>https://yangphd.com/research/causal_inference_basics/causal-inference-difference-in-difference/</link>
      <pubDate>Wed, 16 Jun 2021 00:00:00 +0000</pubDate>
      
      <guid>https://yangphd.com/research/causal_inference_basics/causal-inference-difference-in-difference/</guid>
      <description>


&lt;div id=&#34;the-causality-graph&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;the Causality Graph&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/7DID_files/figure-html/unnamed-chunk-1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-the-differences-in-y-not-explained-by-treatment-and-time&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Remove the Differences in Y NOT explained by Treatment and Time&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/7DID_files/figure-html/unnamed-chunk-2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Matching</title>
      <link>https://yangphd.com/research/causal_inference_basics/causal-inference-matching/</link>
      <pubDate>Wed, 09 Jun 2021 00:00:00 +0000</pubDate>
      
      <guid>https://yangphd.com/research/causal_inference_basics/causal-inference-matching/</guid>
      <description>


&lt;div id=&#34;the-causality-graph&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;the Causality Graph&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/6Matching_files/figure-html/unnamed-chunk-2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;removing-the-differences-in-y-explained-by-x-to-find-out-the-pure-effect-of-treatment-on-y&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Removing the “Differences in Y explained by X” (to find out the pure effect of Treatment on Y)&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/6Matching_files/figure-html/unnamed-chunk-3-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Fixed Effects</title>
      <link>https://yangphd.com/research/causal_inference_basics/causal-inference-fixed-effects/</link>
      <pubDate>Wed, 02 Jun 2021 00:00:00 +0000</pubDate>
      
      <guid>https://yangphd.com/research/causal_inference_basics/causal-inference-fixed-effects/</guid>
      <description>


&lt;div id=&#34;the-causality-graph&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;the Causality Graph&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/5FE_files/figure-html/unnamed-chunk-1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-differences-in-x-explained-by-person-vs.remove-differences-in-y-explained-by-person&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Remove “Differences in X explained by Person” vs. Remove “Differences in Y explained by Person”&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/5FE_files/figure-html/unnamed-chunk-2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-personss-influence-on-the-effect-of-x-on-y-step-by-step&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Remove Persons’s influence on “the effect of X on Y” step by step&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/5FE_files/figure-html/unnamed-chunk-3-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Post-treatment Control</title>
      <link>https://yangphd.com/research/causal_inference_basics/causal-inference-pt-control/</link>
      <pubDate>Wed, 26 May 2021 00:00:00 +0000</pubDate>
      
      <guid>https://yangphd.com/research/causal_inference_basics/causal-inference-pt-control/</guid>
      <description>


&lt;div id=&#34;the-causality-graph&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;the Causality Graph&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/4pt_control_files/figure-html/unnamed-chunk-1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-differences-in-x-explained-by-c-vs.remove-differences-in-y-explained-by-c&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Remove “Differences in X explained by C” vs. Remove “Differences in Y explained by C”&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/4pt_control_files/figure-html/unnamed-chunk-2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-cs-influence-on-x-and-y-step-by-step&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Remove C’s influence on X and Y step by step&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/4pt_control_files/figure-html/unnamed-chunk-3-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Collider Bias</title>
      <link>https://yangphd.com/research/causal_inference_basics/causal-inference-collider-bias/</link>
      <pubDate>Wed, 19 May 2021 00:00:00 +0000</pubDate>
      
      <guid>https://yangphd.com/research/causal_inference_basics/causal-inference-collider-bias/</guid>
      <description>


&lt;div id=&#34;the-causality-graph&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;the Causality Graph&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/3collider_files/figure-html/unnamed-chunk-1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-differences-in-x-explained-by-c-vs.remove-differences-in-y-explained-by-c&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Remove “Differences in X explained by C” vs. Remove “Differences in Y explained by C”&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/3collider_files/figure-html/unnamed-chunk-2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;what-the-model-does-remove-cs-influence-on-x-and-y-step-by-step&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;What the model does: Remove C’s influence on X and Y step by step&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/3collider_files/figure-html/unnamed-chunk-3-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Instrument Variable</title>
      <link>https://yangphd.com/research/causal_inference_basics/causal-inference-instrument-variable/</link>
      <pubDate>Wed, 12 May 2021 00:00:00 +0000</pubDate>
      
      <guid>https://yangphd.com/research/causal_inference_basics/causal-inference-instrument-variable/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#causality-graph&#34;&gt;Causality Graph&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#generate-the-data-for-analysis&#34;&gt;Generate the Data for Analysis&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#visualization&#34;&gt;Visualization&lt;/a&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#remove-differences-in-x-not-explained-by-z-vs.remove-differences-in-y-not-explained-by-z&#34;&gt;Remove “Differences in X NOT explained by Z” vs. Remove “Differences in Y NOT explained by Z”&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#retain-differences-in-x-and-y-explained-by-z-step-by-step&#34;&gt;Retain “Differences in X and Y explained by Z” step by step&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#run-the-regression-and-check-the-estimate-of-x&#34;&gt;Run the Regression and Check the Estimate of X&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;div id=&#34;causality-graph&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Causality Graph&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/2iv_files/figure-html/unnamed-chunk-2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;generate-the-data-for-analysis&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Generate the Data for Analysis&lt;/h1&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# DGP
set.seed(66)
# Z is a binary variable in this case, but it can also be continuous.
df &amp;lt;- data.frame(Z = c(rep(0, 100), rep(1, 100)), 
                 W = rnorm(200)) %&amp;gt;%
  # Z affects X
  mutate(X = .5 + 2*W + 2*Z + rnorm(200)) %&amp;gt;% 
  # Z does NOT affect either Y or W (God&amp;#39;s Game)
  mutate(Y = -X + 4*W + 1 + rnorm(200)) %&amp;gt;% 
  group_by(Z) %&amp;gt;%
  mutate(mean_X=mean(X), mean_Y=mean(Y)) %&amp;gt;%
  ungroup()&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;visualization&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Visualization&lt;/h1&gt;
&lt;div id=&#34;remove-differences-in-x-not-explained-by-z-vs.remove-differences-in-y-not-explained-by-z&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Remove “Differences in X NOT explained by Z” vs. Remove “Differences in Y NOT explained by Z”&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/2iv_files/figure-html/unnamed-chunk-4-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;retain-differences-in-x-and-y-explained-by-z-step-by-step&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Retain “Differences in X and Y explained by Z” step by step&lt;/h2&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/2iv_files/figure-html/unnamed-chunk-5-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;run-the-regression-and-check-the-estimate-of-x&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Run the Regression and Check the Estimate of X&lt;/h1&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;library(AER)
# Z is the instrument variable
summary(ivreg(Y ~ X | Z , data = df)) %&amp;gt;% 
  coef() %&amp;gt;% 
  regrrr::to_long_tab()&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;##   n.r        var_      beta
## 1   1 (Intercept)    1.318*
## 2   1               (0.583)
## 3   2           X -1.089***
## 4   2               (0.300)&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Sample Selection Bias</title>
      <link>https://yangphd.com/research/causal_inference_basics/sample-selection-bias-and-heckman-mode/</link>
      <pubDate>Wed, 12 May 2021 00:00:00 +0000</pubDate>
      
      <guid>https://yangphd.com/research/causal_inference_basics/sample-selection-bias-and-heckman-mode/</guid>
      <description>

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#causality-graph&#34;&gt;Causality Graph&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#dgp&#34;&gt;DGP&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#run-heckman-regression&#34;&gt;Run Heckman Regression&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#visualization&#34;&gt;Visualization&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#double-check&#34;&gt;Double Check&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;div id=&#34;causality-graph&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Causality Graph&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/9Heckman_files/figure-html/unnamed-chunk-2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;dgp&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;DGP&lt;/h1&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;set.seed(66)
# Generate Exogenous Variables
df &amp;lt;- data.frame(X = runif(300) * 10, 
                 W = runif(300) * 5, 
                 U = runif(300) * 2, 
                 Z = c(rep(0, 150), rep(1, 150))) %&amp;gt;%
  # God&amp;#39;s Game
  # X (Visible) affects Y, W (Invisible) and U (Invisible) affect Y
  mutate(Y = .1 + .5*X + 0.8*W + 0.2*U + rnorm(300),
  # X (Visible) affects Y, W (Invisible) and U (Invisible) affect Latent Selection Function
  # Z (Visible) affect Latent Selection Function
         select_ = 10 + 3*X + 2*W + 1*U + .5*Z + rnorm(300),
  # Latent Selection Determines the True Selection
         select = ifelse(select_ &amp;gt; mean(select_), 1, 0)
         )&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;run-heckman-regression&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Run Heckman Regression&lt;/h1&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;run_selection &amp;lt;- glm(select ~ X + Z, family = binomial( link = &amp;quot;probit&amp;quot; ), data = df)
df$IMR &amp;lt;- dnorm(run_selection$linear.predictors)/pnorm(run_selection$linear.predictors)
summary(run_selection)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## glm(formula = select ~ X + Z, family = binomial(link = &amp;quot;probit&amp;quot;), 
##     data = df)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.0059  -0.1287  -0.0013   0.1240   2.5195  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(&amp;gt;|z|)    
## (Intercept)  -5.4514     0.6613  -8.244   &amp;lt;2e-16 ***
## X             1.0163     0.1213   8.380   &amp;lt;2e-16 ***
## Z             0.6183     0.2704   2.287   0.0222 *  
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 415.03  on 299  degrees of freedom
## Residual deviance: 113.84  on 297  degrees of freedom
## AIC: 119.84
## 
## Number of Fisher Scoring iterations: 8&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;run_outcome &amp;lt;- lm(Y ~ IMR + X, data = df[which(df$select == 1),])
summary(run_outcome)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = Y ~ IMR + X, data = df[which(df$select == 1), ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.4067 -0.8600  0.0496  0.7680  3.4331 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept)   2.4928     0.8875   2.809  0.00569 ** 
## IMR           0.9237     0.4398   2.100  0.03749 *  
## X             0.4922     0.1099   4.477 1.56e-05 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 1.338 on 139 degrees of freedom
## Multiple R-squared:  0.1532, Adjusted R-squared:  0.141 
## F-statistic: 12.58 on 2 and 139 DF,  p-value: 9.55e-06&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div id=&#34;visualization&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Visualization&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/9Heckman_files/figure-html/unnamed-chunk-5-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;double-check&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Double Check&lt;/h1&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Run OLS (which is biased)
run_biased &amp;lt;- lm(Y ~ X, data = df[which(df$select == 1),])
summary(run_biased)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = Y ~ X, data = df[which(df$select == 1), ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.5643 -0.9695  0.1065  0.7926  3.2590 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept)   4.0168     0.5172   7.766 1.55e-12 ***
## X             0.3114     0.0692   4.500 1.42e-05 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 1.354 on 140 degrees of freedom
## Multiple R-squared:  0.1263, Adjusted R-squared:  0.1201 
## F-statistic: 20.25 on 1 and 140 DF,  p-value: 1.419e-05&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# Check the Inclusion Restriction
run_test_instrument &amp;lt;- lm(Y ~ X + Z, data = df[which(df$select == 1),])
summary(run_test_instrument)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = Y ~ X + Z, data = df[which(df$select == 1), ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.3369 -0.9958  0.1245  0.8445  3.1289 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept)  3.71761    0.54715   6.794 2.93e-10 ***
## X            0.32192    0.06913   4.657 7.42e-06 ***
## Z            0.37117    0.23158   1.603    0.111    
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 1.347 on 139 degrees of freedom
## Multiple R-squared:  0.1422, Adjusted R-squared:  0.1299 
## F-statistic: 11.52 on 2 and 139 DF,  p-value: 2.347e-05&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# In Reality, Only God Can Run This Regression (by Knowing about the Truth and Seeing the Invisibles).
run_ture &amp;lt;- lm(Y ~ U + W + X, data = df)
summary(run_ture)&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;## 
## Call:
## lm(formula = Y ~ U + W + X, data = df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -3.02525 -0.64811 -0.01175  0.56035  2.71664 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept) 0.008025   0.188084   0.043  0.96600    
## U           0.330793   0.099258   3.333  0.00097 ***
## W           0.773520   0.040014  19.331  &amp;lt; 2e-16 ***
## X           0.499843   0.020288  24.637  &amp;lt; 2e-16 ***
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1
## 
## Residual standard error: 0.9544 on 296 degrees of freedom
## Multiple R-squared:  0.7703, Adjusted R-squared:  0.768 
## F-statistic: 330.9 on 3 and 296 DF,  p-value: &amp;lt; 2.2e-16&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Control Variable</title>
      <link>https://yangphd.com/research/causal_inference_basics/causal-inference-control-variable/</link>
      <pubDate>Wed, 05 May 2021 00:00:00 +0000</pubDate>
      
      <guid>https://yangphd.com/research/causal_inference_basics/causal-inference-control-variable/</guid>
      <description>


&lt;div id=&#34;the-causality-graph&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;the Causality Graph&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/1control_files/figure-html/unnamed-chunk-1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;simpsons-paradox&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Simpson’s Paradox&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/1control_files/figure-html/unnamed-chunk-2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-differences-in-x-explained-by-w-vs.remove-differences-in-y-explained-by-w&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Remove “Differences in X explained by W” vs. Remove “Differences in Y explained by W”&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/1control_files/figure-html/unnamed-chunk-3-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;remove-ws-influence-on-x-and-y-step-by-step&#34; class=&#34;section level1&#34;&gt;
&lt;h1&gt;Remove W’s influence on X and Y step by step&lt;/h1&gt;
&lt;p&gt;&lt;img src=&#34;https://yangphd.com/research/causal_inference_basics/1control_files/figure-html/unnamed-chunk-4-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
  </channel>
</rss>