<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/lords-paradox-in-r/"></div></div><div><a data-url="https://www.r-bloggers.com/lords-paradox-in-r/" data-counturl="https://www.r-bloggers.com/lords-paradox-in-r/" data-count="horizontal" data-text="Lord’s Paradox in R" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://hagutierrezro.blogspot.com/2016/11/lord-paradox-in-r.html"> Data Literacy - The blog of Andrés Gutiérrez</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>In an article called A Paradox in the Interpretation of Group Comparisons published in Psychological Bulletin, Lord (1967) made famous the following controversial story:</p>
<blockquote><p><em>A university is interested in investigating the effects of the nutritional diet its students consume in the campus restaurant. Various types of data were collected including the weight of each student in the month of January and their weight in the month of June of the same year. The objective of the University is to know if the diet has greater effects on men than on women. This information is analyzed by two statisticians.</em></p>
<p><em>The first statistician observes that at the end of the semester (June), the average weight of the men is identical to their average weight at the beginning of the semester (January). This situation also occurs for women. The only difference is that women started the year with a lower average weight (which is obvious from their background). On average, neither men nor women gained or lost weight during the course of the semester. The first statistician concludes that there is no evidence of any significant effect of diet (or any other factor) on student weight. In particular, there is no evidence of any differential effect on both sexes, since no group shows systematic differences.</em></p>
<p><em>The second statistician examines the data more carefully. Note that there is a group of men and women who started the semester with the same weight. This group consisted of thin men and overweight women. He notes that those men gained weight from the average and these women lost weight with respect to the average. The second statistician concludes that by controlling for the initial weight, the university diet has a positive differential effect on men relative to women. It is evident that for men and women with the same initial weight, on average they differ since men gained more weight, and women lost more weight.</em></p>
</blockquote>
<p>The following chart shows the reasoning of both statisticians in dealing with the problem. Note that the black line describes a 45 degrees line, the green points are the data coming from the men and the red ones from the women</p>
<p><img title="Screen Shot 2016-11-20 at 6.04.27 PM.png" alt="Screen Shot 2016 11 20 at 6 04 27 PM" src="https://i0.wp.com/lh3.googleusercontent.com/-zrVFns8FA4U/WDIsaNDxNUI/AAAAAAAAAYE/IHAR97qvd5Q/Screen%252520Shot%2525202016-11-20%252520at%2525206.04.27%252520PM.png?resize=367%2C250&ssl=1" border="0" data-recalc-dims="1"></p>
<p>The reasoning of the first statistician focuses on the expectations of both distributions. Specifically in the coordinates (x = 60, y = 60), for females, and (x = 70, y = 70) for males, where black, red and green lines appear to coincide. The reasoning of the second statistic is limited to the continuum induced by the overlap of red and green dots. Specifically to the space induced by x = (60, 70), y = (60, 70). Suppose we have access to this dataset as shown in the following illustration, where the first column denotes the initial weight of the students, the second column indicates the final weight, the third column describes the difference between pesos and the last one defines the Sex of the student.</p>
<p><img title="Screen Shot 2015-12-30 at 11.13.09 PM.png" alt="Screen Shot 2015 12 30 at 11 13 09 PM" src="https://i0.wp.com/lh3.googleusercontent.com/-2L7VAwbck_k/VoSrpKTh-CI/AAAAAAAAAKQ/Jmil2kqkYyo/Screen%252520Shot%2525202015-12-30%252520at%25252011.13.09%252520PM.png?resize=456%2C226&ssl=1" border="0" data-recalc-dims="1"></p>
<p>The findings of the first statistician are obtained through a simple regression analysis that, taking as a response variable the difference between weights, induces a coefficient of regression equal to zero for the variable sex, which indicates that there are no significant differences in the weight difference between men and women.</p>
<p><img title="Screen Shot 2016-11-20 at 6.04.49 PM.png" alt="Screen Shot 2016 11 20 at 6 04 49 PM" src="https://i2.wp.com/lh3.googleusercontent.com/-CtrVgp1JqKA/WDIspRi-U1I/AAAAAAAAAYM/zSA7XoPEqbc/Screen%252520Shot%2525202016-11-20%252520at%2525206.04.49%252520PM.png?resize=376%2C250&ssl=1" border="0" data-recalc-dims="1"></p>
<p>The findings of the second statistic are obtained through a covariance analysis, taking as response variable the final weight and covariates are sex and the initial weight of the individual. This method induces a coefficient of regression equal to 5.98 which implies that there is significant difference between the final weight of the people, according to sex.</p>
<p><img title="Screen Shot 2016-11-20 at 6.05.28 PM.png" alt="Screen Shot 2016 11 20 at 6 05 28 PM" src="https://i1.wp.com/lh3.googleusercontent.com/-R4ymRCzvwmQ/WDIswGKB-FI/AAAAAAAAAYU/6UcnriQC0K0/Screen%252520Shot%2525202016-11-20%252520at%2525206.05.28%252520PM.png?resize=374%2C256&ssl=1" border="0" data-recalc-dims="1"></p>
<p>For Imbens and Rubin (2015), both are right when it comes to describing the data, although both lack a sound reasoning in establishing some kind of causality between the diet of the university and the loss or gain of weight in the students. Regardless of this I still find more interesting the analysis that arises from the comparison between men and women who started with the same weight (ie all data restricted to x = (60, 70) y = (60, 70). </p>
<h1>R workshop</h1>
<p>Lord’s paradox summarizes the analysis of two statisticians who analyze the average weight of some students within a particular university. At the end of the semester (June), the average weight of the men is identical to their average weight at the beginning of that six months (January). This situation also occurs for women. The only difference is that women started the year with a lower average weight (which is evident from their natural contexture). On average, neither men nor women gained or lost weight during the semester.</p>
<p>To perform the simulation, we assumed that both the final weight of the men and the women follow a linear relationship with the original weight. Thus, it is assumed that $y_{2i}^M = \beta_0^M + \beta_1 y_{1i}^M + \varepsilon_i$ for the weight of women; and $y_{2i}^H = \beta_0^H + \beta_1 y_{1i}^H + \varepsilon_i$, for the weight of men. Where $y_{1i}^M$ denotes the weight of the $i$-th female at the beginning of the semester, and $y_{2i}^M$ denotes the weight of the $i$-th female at the end of the semester. The notation for men (H) maintains this logic.</p>
<p>Now, note that from their natural contexture, men must have greater weight than women. Suppose that on average the weight of men is equal to that of women plus a constant $c$. In addition, the mean weight in both groups is identical in both times. Then, we have $\bar{y}^M = \beta_0^M + \beta_1 \bar{y}^M$ and that $\bar{y}^H = \beta_0^H + \beta_1 \bar{y}^H = \beta_0^H + \beta_1 (\bar{y}^M + c).$ Hence, after some algebra, we have that $\beta_0^M = (1 – \beta_1) \bar{y}^M$ and $\beta_0^H = \bar{y}^H – \beta_1 (\bar{y}^M + c)$.</p>
<p>The following code replicates a set of data that follows the relationship proposed by Lord.</p>
<pre>N &lt;- <span>1000</span><br> <br>b &lt;- <span>10</span><br>l &lt;- <span>50</span><br>u &lt;- <span>70</span><br>Mujer1 &lt;- <a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/stats/runif"><span>runif</span></a><span>(</span>N<span>,</span> l<span>,</span> u<span>)</span><br>Hombre1 &lt;- Mujer1 + b<br> <br>beta1 &lt;- <span>0.4</span><br>Mujerb0 &lt;- <span>(</span><span>1</span> - beta1<span>)</span> * <a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/base/mean"><span>mean</span></a><span>(</span>Mujer1<span>)</span><br>Hombreb0 &lt;- <a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/base/mean"><span>mean</span></a><span>(</span>Hombre1<span>)</span> - beta1 * <span>(</span><a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/base/mean"><span>mean</span></a><span>(</span>Mujer1<span>)</span> + b<span>)</span><br> <br>sds &lt;- <span>1</span><br>Mujer2 &lt;- Mujerb0 + beta1 * Mujer1 + <a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/stats/rnorm"><span>rnorm</span></a><span>(</span>N<span>,</span> <a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/stats/sd"><span>sd</span></a>=sds<span>)</span><br>Hombre2 &lt;- Hombreb0 + beta1 * Hombre1 + <a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/stats/rnorm"><span>rnorm</span></a><span>(</span>N<span>,</span> <a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/stats/sd"><span>sd</span></a>=sds<span>)</span></pre>
<p>The graph can be done with the following piece of code:</p>
<pre>datos &lt;- <a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/base/data.frame"><span>data.frame</span></a><span>(</span>inicio = <a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/base/c"><span>c</span></a><span>(</span>Mujer1<span>,</span> Hombre1<span>)</span><span>,</span> final = <a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/base/c"><span>c</span></a><span>(</span>Mujer2<span>,</span> Hombre2<span>)</span><span>)</span><br>datos$dif &lt;- datos$final - datos$inicio<br>datos$sexo = <a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/base/c"><span>c</span></a><span>(</span><a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/base/rep"><span>rep</span></a><span>(</span><span>0</span><span>,</span> N<span>)</span><span>,</span> <a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/base/rep"><span>rep</span></a><span>(</span><span>1</span><span>,</span> N<span>)</span><span>)</span><br> <br><a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/base/library"><span>library</span></a><span>(</span><a target="_blank" rel="nofollow" href="http://inside-r.org/packages/cran/ggplot2">ggplot2</a><span>)</span><br><a target="_blank" rel="nofollow" href="http://inside-r.org/packages/cran/ggplot">ggplot</a><span>(</span><a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/utils/data"><span>data</span></a> = datos<span>,</span> aes<span>(</span>inicio<span>,</span> final<span>,</span> color = <a target="_blank" rel="nofollow" href="http://inside-r.org/r-doc/base/factor"><span>factor</span></a><span>(</span>sexo<span>)</span><span>)</span><span>)</span> +<br>  geom_point<span>(</span><span>)</span> + stat_smooth<span>(</span>method = <span>&quot;lm&quot;</span><span>)</span>  +<br>  geom_abline<span>(</span>intercept = <span>0</span><span>,</span> slope = <span>1</span><span>)</span> +<br>  ggtitle<span>(</span><span>&quot;Paradoja de Lord&quot;</span><span>)</span> + theme_bw<span>(</span><span>)</span></pre>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/lords-paradox-in-r/"></div></div><div><a data-url="https://www.r-bloggers.com/lords-paradox-in-r/" data-counturl="https://www.r-bloggers.com/lords-paradox-in-r/" data-count="vertical" data-text="Lord’s Paradox in R" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://hagutierrezro.blogspot.com/2016/11/lord-paradox-in-r.html"> Data Literacy - The blog of Andrés Gutiérrez</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/lKo-DgTcxxI"></a></div>