<div> I’m currently working on my <a rel="nofollow" href="http://www.deeplytrivial.com/2018/04/statistics-sunday-conducting-meta.html" target="_blank">promised video on mixed effects meta-analysis</a>, and was planning on covering this particular topic in that video – converting between <a rel="nofollow" href="http://www.deeplytrivial.com/2018/04/e-is-for-effect-sizes.html" target="_blank">effect sizes</a>. But I decided to do this as a separate post that I can reference in the video, which I hope to post next week.
<p>As a brief refresher, <a rel="nofollow" href="http://www.deeplytrivial.com/2017/04/m-is-for-meta-analysis.html" target="_blank">meta-analysis</a> is aimed at estimating the true effect (or effects) in an area of study by combining findings from multiple studies on that topic. Effect sizes, the most frequently used being <a rel="nofollow" href="http://www.deeplytrivial.com/2017/08/statistics-sunday-introduction-to.html" target="_blank">Cohen’s d</a>, <a rel="nofollow" href="http://www.deeplytrivial.com/2017/04/r-is-for-r-correlation.html" target="_blank">Pearson’s r</a>, and <a rel="nofollow" href="http://www.deeplytrivial.com/2017/09/statistics-sunday-everyone-loves-log.html" target="_blank">log odds ratio</a>, are estimated from information in study reports and presentations. There’s a lot of variation in how clearly reports and documents describe the findings and the information given to estimate the study’s overall effect. But when you conduct the meta-analysis, whether using fixed, random, or mixed effects analysis, you need to use only one type of effect size. That means that, sometimes, studies will give you a different type of effect size than you plan to use. Fortunately, there are ways to convert between effect sizes and use different types of statistical information to generate your estimates. </p>
<p>First up, converting between those key effect sizes. In the meta-analysis I performed in grad school, I examined the effect of pretrial publicity on guilt. There are two ways guilt was frequently operationalized in the studies: as a guilty/not guilty verdict or as a continuous guilt rating. For those outcomes, we would likely use, respectively, log odds ratio and Cohen’s d. The escalc function in the metafor package can compute log odds ratio for guilty/not guilty counts, and Cohen’s d for mean and standard deviation of the guilt ratings. But studies may use different types of information when presenting their results, so you may not be able to simply compute those effect sizes.</p>
<p>For instance, a study using verdict may present a <a rel="nofollow" href="http://www.deeplytrivial.com/2017/06/statistics-sunday-chi-square-anova-for.html" target="_blank">chi-square</a> and one of its effect sizes, Cramer’s V, which is very similar to a correlation coefficient. How can I convert that into log odds ratio?</p>
<p>To convert from one effect size to the other, you need to follow <a rel="nofollow" href="https://www.meta-analysis.com/downloads/Meta-analysis%20Converting%20among%20effect%20sizes.pdf" target="_blank">a prescribed path</a>, which can be seen in the diagram below. What this diagram tells you is which effect sizes you can convert between directly: you can directly convert between log odds ratio and Cohen’s d, and between Cohen’s d and Pearson’s r. If you wanted to convert between Pearson’s r and log odds ratio, you’ll first need to convert to Cohen’s d. You’ll need to do the same thing for variance – compute it for the native effect size metric, then convert that to the new effect size metric.</p>
<div><a rel="nofollow" href="https://i1.wp.com/1.bp.blogspot.com/-pO1kbe1S8nw/Wy1V4iq0pKI/AAAAAAAAMA8/tZWEv4lp6ncylOR9nJokF51pvDxHsxrqQCLcBGAs/s1600/diagram_start.jpg?ssl=1" target="_blank"><img border="0" src="https://i0.wp.com/1.bp.blogspot.com/-pO1kbe1S8nw/Wy1V4iq0pKI/AAAAAAAAMA8/tZWEv4lp6ncylOR9nJokF51pvDxHsxrqQCLcBGAs/s320/diagram_start.jpg?resize=450%2C92&ssl=1" data-original-width="450" width="450" data-original-height="92" data-recalc-dims="1"></a></div>
<p>Let’s start by setting up functions that will convert between our effect sizes for us, beginning with Cohen’s d and log odds ratio. Then we’ll demonstrate with some real data.</p>
<div>
<div>
<div>
<pre><span>#Convert log odds ratio to d</span><br><span>ltod</span> <span>&lt;-</span> <span>function</span><span>(</span><span>lor</span><span>) {</span><br>  <span>d</span> <span>=</span> <span>lor</span> <span>*</span> <span>(</span><span>sqrt</span><span>(</span><span>3</span><span>)</span><span>/</span><span>pi)</span><br>  <span>return</span><span>(d)</span><br><span>}</span><br><span>vltovd</span> <span>&lt;-</span> <span>function</span><span>(</span><span>vl</span><span>) {</span><br>  <span>vd</span> <span>=</span> <span>vl</span> <span>*</span> <span>(</span><span>3</span><span>/</span><span>pi</span><span>^</span><span>2</span><span>)</span><br>  <span>return</span><span>(vd)</span><br><span>}</span><br><br><span>#Convert d to log odds ratio</span><br><span>dtol</span> <span>&lt;-</span> <span>function</span><span>(</span><span>d</span><span>) {</span><br>  <span>lor</span> <span>=</span> <span>d</span><span>*</span><span>(pi</span><span>/</span><span>sqrt</span><span>(</span><span>3</span><span>))</span><br>  <span>return</span><span>(lor)</span><br><span>}</span><br><span>vdtovl</span> <span>&lt;-</span> <span>function</span><span>(</span><span>vd</span><span>) {</span><br>  <span>vl</span> <span>=</span> <span>vd</span><span>*</span><span>(pi</span><span>^</span><span>2</span><span>/</span><span>3</span><span>)</span><br>  <span>return</span><span>(vl)</span><br><span>}</span><br></pre>
</div>
</div>
</div>
<p>You’ll notice a mathematical symmetry in these equations – the numerators and denominators switch between the equations. Now let’s set up equations to r and d. These equations are slightly more complex and will require a few additional arguments. For instance, converting the variance of r to variance of d requires both the variance of r and r itself. Converting from d to r requires group sample sizes, referred to as n1 and n2.</p>
<div>
<div>
<div>
<pre><span>#Convert r to d</span><br><span>rtod</span> <span>&lt;-</span> <span>function</span><span>(</span><span>r</span><span>) {</span><br>  <span>d</span> <span>=</span> <span>(</span><span>2</span><span>*</span><span>r)</span><span>/</span><span>(</span><span>sqrt</span><span>(</span><span>1</span><span>-</span><span>r</span><span>^</span><span>2</span><span>))</span><br>  <span>return</span><span>(d)</span><br><span>}</span><br><span>vrtovd</span> <span>&lt;-</span> <span>function</span><span>(</span><span>vr</span><span>,</span><span>r</span><span>) {</span><br>  <span>vd</span> <span>=</span> <span>(</span><span>4</span><span>*</span><span>vr)</span><span>/</span><span>(</span><span>1</span><span>-</span><span>r</span><span>^</span><span>2</span><span>)</span><span>^</span><span>3</span><br>  <span>return</span><span>(vd)</span><br><span>}</span><br><br><span>#Convert d to r</span><br><span>dtor</span> <span>&lt;-</span> <span>function</span><span>(</span><span>n1</span><span>,</span><span>n2</span><span>,</span><span>d</span><span>) {</span><br>  <span>a</span> <span>=</span> <span>(n1</span><span>+</span><span>n2)</span><span>^</span><span>2</span><span>/</span><span>(n1</span><span>*</span><span>n2)</span><br>  <span>r</span> <span>=</span> <span>d</span><span>/</span><span>(</span><span>sqrt</span><span>(d</span><span>^</span><span>2</span><span>+</span><span>a))</span><br>  <span>return</span><span>(r)</span><br><span>}</span><br><span>vdtovr</span> <span>&lt;-</span> <span>function</span><span>(</span><span>n1</span><span>,</span><span>n2</span><span>,</span><span>vd</span><span>,</span><span>d</span><span>) {</span><br>  <span>a</span> <span>=</span> <span>(n1</span><span>+</span><span>n2)</span><span>^</span><span>2</span><span>/</span><span>(n1</span><span>*</span><span>n2)</span><br>  <span>vr</span> <span>=</span> <span>a</span><span>^</span><span>2</span><span>*</span><span>vd</span><span>/</span><span>(d</span><span>^</span><span>2</span><span>+</span><span>a)</span><span>^</span><span>3</span><br>  <span>return</span><span>(vr)</span><br><span>}</span><br></pre>
</div>
</div>
</div>
<p>Remember that the metafor package can compute effect sizes and variances for you, so you might want to run the escalc on the native effect sizes so that you have the estimates and variances you need to run these functions. But if you ever find yourself having to compute those variances by hand, here are the equations, which we’ll use in the next step.</p>
<div>
<div>
<div>
<pre><span>vard</span> <span>&lt;-</span> <span>function</span><span>(</span><span>n1</span><span>,</span><span>n2</span><span>,</span><span>d</span><span>) {</span><br>  <span>vd</span> <span>=</span> <span>((n1</span><span>+</span><span>n2)</span><span>/</span><span>(n1</span><span>*</span><span>n2))</span> <span>+</span> <span>(d</span><span>^</span><span>2</span><span>/</span><span>(</span><span>2</span><span>*</span><span>(n1</span><span>+</span><span>n2)))</span><br>  <span>return</span><span>(vd)</span><br><span>}</span><br><br><span>varr</span> <span>&lt;-</span> <span>function</span><span>(</span><span>r</span><span>,</span><span>n</span><span>) {</span><br>  <span>vr</span> <span>=</span> <span>(</span><span>1</span><span>-</span><span>r</span><span>^</span><span>2</span><span>)</span><span>^</span><span>2</span><span>/</span><span>(n</span><span>-</span><span>1</span><span>)</span><br>  <span>return</span><span>(vr)</span><br><span>}</span><br><br><span>varlor</span> <span>&lt;-</span> <span>function</span><span>(</span><span>a</span><span>,</span><span>b</span><span>,</span><span>c</span><span>,</span><span>d</span><span>) {</span><br>  <span>vl</span> <span>=</span> <span>(</span><span>1</span><span>/</span><span>a)</span><span>+</span><span>(</span><span>1</span><span>/</span><span>b)</span><span>+</span><span>(</span><span>1</span><span>/</span><span>c)</span><span>+</span><span>(</span><span>1</span><span>/</span><span>d)</span><br>  <span>return</span><span>(vl)</span><br><span>}</span><br></pre>
</div>
</div>
</div>
<p>One of the studies I included in my meta-analysis gave Cramer’s V. It had a sample size of 42, with 21 people in each group. I’d like to convert that effect size to log odds ratio. Here’s how I could do it.</p>
<div>
<div>
<div>
<pre><span>cramerv</span> <span>&lt;-</span> <span>0.67</span><br><span>studyd</span> <span>&lt;-</span> <span>rtod</span><span>(cramerv)</span><br><span>studyvr</span> <span>&lt;-</span> <span>varr</span><span>(</span><span>0.67</span><span>,</span><span>42</span><span>)</span><br><span>studyvd</span> <span>&lt;-</span> <span>vrtovd</span><span>(studyvr,cramerv)</span><br><span>dtol</span><span>(studyd)</span><br></pre>
</div>
<div>
<pre>## [1] 3.274001<br></pre>
</div>
<div>
<pre><span>vdtovl</span><span>(studyvd)</span><br></pre>
</div>
<div>
<pre>## [1] 0.5824038<br></pre>
</div>
</div>
</div>
<p>I can now include this study in my meta-analysis of log odds ratios.</p>
<p>What if my study gives different information? For instance, it might have given me a chi-square or a t-value. This <a rel="nofollow" href="http://www.campbellcollaboration.org/escalc/html/EffectSizeCalculator-Home.php" target="_blank">online effect size calculator</a>, created by David Wilson, coauthor of <i><a rel="nofollow" href="https://www.amazon.com/Practical-Meta-Analysis-Applied-Research-Methods/dp/0761921680/ref=sr_1_1?ie=UTF8&qid=1529698091&sr=8-1&keywords=practical+metaanalysis" target="_blank">Practical Meta-Analysis</a></i>, can compute effect sizes for you from many different types of information. In fact, spoiler alert: I used an earlier version of this calculator extensively for my meta-analysis. Note that this calculator returns odds ratios, so you’ll need to convert those values into a log odds ratio. </p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.deeplytrivial.com/2018/06/statistics-sunday-converting-between.html"> Deeply Trivial</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 rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/79axgO9oV0Y" height="1"></a></div></div>