<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="http://www.r-bloggers.com/divide-by-4-rule-for-marginal-effects/"></div></div><div><a data-url="http://www.r-bloggers.com/divide-by-4-rule-for-marginal-effects/" data-counturl="http://www.r-bloggers.com/divide-by-4-rule-for-marginal-effects/" data-count="horizontal" data-text="Divide by 4 Rule for Marginal Effects" 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://econometricsense.blogspot.com/2016/05/divide-by-4-rule-for-marginal-effects.html"> Econometric Sense</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Previously I wrote about the practical differences between <a target="_blank" href="http://econometricsense.blogspot.com/2016/03/marginal-effects-vs-odds-ratios_11.html">marginal effects and odds ratios</a> with regard to logistic regression. </p>
<p>Recently, I ran across a tweet from Michael Grogan linking to one of his <a target="_blank" href="http://www.michaeljwgrogan.com/binomial-logistic-regression-an-analysis-of-stock-dividends/">posts </a>using logistic regression to model dividend probabilities. This really got me interested:</p>
<p><i>“Moreover, to obtain a measure in probability terms – one could divide the logit coefficient by 4 to obtain an estimate of the probability of a dividend increase. In this case, the logit coefficient of 0.8919 divided by 4 gives us a result of 22.29%, which means that for every 1 year increase in consecutive dividend increases, the probability of an increase in the dividend this year rises by 22.29%.”</i></p>
<p>I had never heard of this ‘divide by 4′ short cut to get to marginal effects. While you can get those in STATA, R or SAS with a little work, I think this trick would be very handy for instance if you are reading someone else’s paper/results and just wanted a ballpark on marginal effects (instead of interpreting odds ratios).</p>
<p>I did some additional investigation on this and ran across Stephen Turner’s <a target="_blank" href="http://www.gettinggeneticsdone.com/2010/12/using-divide-by-4-rule-to-interpret.html">Getting Genetics Done blog post</a> related to this, where he goes a little deeper into the mathematics behind this:</p>
<p><i>“The slope of this curve (1st derivative of the logistic curve) is maximized at a+ßx=0, where it takes on the value:</i><i><br>ße<sup>0</sup>/(1+e<sup>0</sup>)²</i><i><br>=ß(1)/(1+1)²</i><i><br>=ß/4 </i><i><br>So you can take the logistic regression coefficients (not including the intercept) and divide them by 4 to get an upper bound of the predictive difference in probability of the outcome y=1 per unit increase in x.”</i></p>
<p>Stephen points to Andrew Gelman, who may be the originator of this, citing the text <i>Data Analysis Using Regression and Multilevel/Hierarchical Models</i> by Andrew Gelman, Jennifer Hill. There is some pushback in the comments to Stephen’s post, but I still think this is a nice shortcut for an on the fly interpretation of reported results. </p>
<p>If you go back to the output from my previous post on marginal effects, the estimated logistic regression coefficients were:</p>
<p>             <b>      Estimate Std. Error z value Pr(>|z|)  </b><br><b>(Intercept)  5.92972    2.34258   2.531   0.0114 *<br>age            -0.14099    0.05656  -2.493   0.0127 *</b></p>
<p>And if you apply the divide by 4 rule you get:</p>
<p><b>-0.14099 / 4 = -.0352</b></p>
<p>While this is not a proof, or even a simulation, it is close to the minimum (which would be the upper bound for negative marginal effects) for this data (see full R program below):</p>
<p><b>summary(meffx) </b><br><b>   Min.  1st Qu.   Median     Mean  3rd Qu.     Max. <br><u>-0.03525 </u>-0.03262 -0.02697 -0.02583 -0.02030 -0.01071 </b></p>
<p>R Code:</p>
<div>
<div>
<pre> <span>#------------------------------------------------------------------</span><br> <span># PROGRAM NAME: MEFF and Odds Ratios</span><br> <span># DATE: 3/3/16</span><br> <span># CREATED BY: MATT BOGARD</span><br> <span># PROJECT FILE: </span><br> <span>#------------------------------------------------------------------</span><br> <span># PURPOSE: GENERATE MARGINAL EFFECTS FOR LOGISTIC REGRESSION AND COMPARE TO:</span><br> <span># ODDS RATIOS / RESULTS FROM R</span><br> <span>#</span><br> <span># REFERENCES: https://statcompute.wordpress.com/2012/09/30/marginal-effects-on-binary-outcome/</span><br> <span># https://diffuseprior.wordpress.com/2012/04/23/probitlogit-marginal-effects-in-r-2/</span><br> <span>#</span><br> <span># UCD CENTRE FOR ECONOMIC RESEARCH </span><br> <span># WORKING PAPER SERIES </span><br> <span># 2011 </span><br> <span># Simple Logit and Probit Marginal Effects in R </span><br> <span># Alan Fernihough, University College Dublin </span><br> <span># WP11/22 </span><br> <span># October 2011 </span><br> <span># http://www.ucd.ie/t4cms/WP11_22.pdf</span><br> <span>#------------------------------------------------------------------;</span><br> <br> <br><span>#-----------------------------------------------------</span><br><span># generate data for continuous explantory variable</span><br><span>#----------------------------------------------------</span><br> <br> <br>Input = <span>(</span><span>&quot;participate age<br>1 25<br>1 26<br>1 27<br>1 28<br>1 29<br>1 30<br>0 31<br>1 32<br>1 33<br>0 34<br>1 35<br>1 36<br>1 37<br>1 38<br>0 39<br>0 40<br>0 41<br>1 42<br>1 43<br>0 44<br>0 45<br>1 46<br>1 47<br>0 48<br>0 49<br>0 50<br>0 51<br>0 52<br>1 53<br>0 54<br>&quot;</span><span>)</span><br> <br>dat1 &lt;-  <a target="_blank" href="http://inside-r.org/r-doc/utils/read.table"><span>read.table</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/textConnection"><span>textConnection</span></a><span>(</span>Input<span>)</span><span>,</span>header=<span>TRUE</span><span>)</span><br> <br><a target="_blank" href="http://inside-r.org/r-doc/base/summary"><span>summary</span></a><span>(</span>dat1<span>)</span> <span># summary stats</span><br> <br><span>#### run logistic regression model</span><br> <br>mylogit &lt;- <a target="_blank" href="http://inside-r.org/r-doc/stats/glm"><span>glm</span></a><span>(</span>participate ~ age<span>,</span> <a target="_blank" href="http://inside-r.org/r-doc/utils/data"><span>data</span></a> = dat1<span>,</span> <a target="_blank" href="http://inside-r.org/r-doc/stats/family"><span>family</span></a> = <span>&quot;binomial&quot;</span><span>)</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/summary"><span>summary</span></a><span>(</span>mylogit<span>)</span><br> <br><a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/cbind"><span>cbind</span></a><span>(</span>OR = <a target="_blank" href="http://inside-r.org/r-doc/stats/coef"><span>coef</span></a><span>(</span>mylogit<span>)</span><span>,</span> <a target="_blank" href="http://inside-r.org/r-doc/stats/confint"><span>confint</span></a><span>(</span>mylogit<span>)</span><span>)</span><span>)</span> <span># get odds ratios</span><br> <br><span>#-------------------------------------------------</span><br>| marginal <a target="_blank" href="http://inside-r.org/r-doc/stats/effects"><span>effects</span></a> calculations<br><span>#-------------------------------------------------</span><br> <br> <br><span>#--------------------------------------------------------------------</span><br><span># mfx function for maginal effects from a glm model</span><br><span>#</span><br><span># from: https://diffuseprior.wordpress.com/2012/04/23/probitlogit-marginal-effects-in-r-2/ </span><br><span># based on:</span><br><span># UCD CENTRE FOR ECONOMIC RESEARCH </span><br><span># WORKING PAPER SERIES </span><br><span># 2011 </span><br><span># Simple Logit and Probit Marginal Effects in R </span><br><span># Alan Fernihough, University College Dublin </span><br><span># WP11/22 </span><br><span>#October 2011 </span><br><span># http://www.ucd.ie/t4cms/WP11_22.pdf</span><br><span>#---------------------------------------------------------------------</span><br> <br>mfx &lt;- <a target="_blank" href="http://inside-r.org/r-doc/base/function"><span>function</span></a><span>(</span>x<span>,</span>sims=<span>1000</span><span>)</span><span>{</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/set.seed"><span>set.seed</span></a><span>(</span><span>1984</span><span>)</span><br><a target="_blank" href="http://inside-r.org/r-doc/grDevices/pdf"><span>pdf</span></a> &lt;- <a target="_blank" href="http://inside-r.org/r-doc/base/ifelse"><span>ifelse</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/as.character"><span>as.character</span></a><span>(</span>x$call<span>)</span><span>[</span><span>3</span><span>]</span>==<span>&quot;binomial(link = <span>&quot;</span>probit<span>&quot;</span>)&quot;</span><span>,</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/mean"><span>mean</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/stats/dnorm"><span>dnorm</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/stats/predict"><span>predict</span></a><span>(</span>x<span>,</span> type = <span>&quot;link&quot;</span><span>)</span><span>)</span><span>)</span><span>,</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/mean"><span>mean</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/stats/dlogis"><span>dlogis</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/stats/predict"><span>predict</span></a><span>(</span>x<span>,</span> type = <span>&quot;link&quot;</span><span>)</span><span>)</span><span>)</span><span>)</span><br>pdfsd &lt;- <a target="_blank" href="http://inside-r.org/r-doc/base/ifelse"><span>ifelse</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/as.character"><span>as.character</span></a><span>(</span>x$call<span>)</span><span>[</span><span>3</span><span>]</span>==<span>&quot;binomial(link = <span>&quot;</span>probit<span>&quot;</span>)&quot;</span><span>,</span><br><a target="_blank" href="http://inside-r.org/r-doc/stats/sd"><span>sd</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/stats/dnorm"><span>dnorm</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/stats/predict"><span>predict</span></a><span>(</span>x<span>,</span> type = <span>&quot;link&quot;</span><span>)</span><span>)</span><span>)</span><span>,</span><br><a target="_blank" href="http://inside-r.org/r-doc/stats/sd"><span>sd</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/stats/dlogis"><span>dlogis</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/stats/predict"><span>predict</span></a><span>(</span>x<span>,</span> type = <span>&quot;link&quot;</span><span>)</span><span>)</span><span>)</span><span>)</span><br>marginal.effects &lt;- <a target="_blank" href="http://inside-r.org/r-doc/grDevices/pdf"><span>pdf</span></a>*<a target="_blank" href="http://inside-r.org/r-doc/stats/coef"><span>coef</span></a><span>(</span>x<span>)</span><br>sim &lt;- <a target="_blank" href="http://inside-r.org/r-doc/base/matrix"><span>matrix</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/rep"><span>rep</span></a><span>(</span><span>NA</span><span>,</span>sims*<a target="_blank" href="http://inside-r.org/r-doc/base/length"><span>length</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/stats/coef"><span>coef</span></a><span>(</span>x<span>)</span><span>)</span><span>)</span><span>,</span> <a target="_blank" href="http://inside-r.org/r-doc/base/nrow"><span>nrow</span></a>=sims<span>)</span><br><span>for</span><span>(</span>i <span>in</span> <span>1</span>:<a target="_blank" href="http://inside-r.org/r-doc/base/length"><span>length</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/stats/coef"><span>coef</span></a><span>(</span>x<span>)</span><span>)</span><span>)</span><span>{</span><br>sim<span>[</span><span>,</span>i<span>]</span> &lt;- <a target="_blank" href="http://inside-r.org/r-doc/stats/rnorm"><span>rnorm</span></a><span>(</span>sims<span>,</span><a target="_blank" href="http://inside-r.org/r-doc/stats/coef"><span>coef</span></a><span>(</span>x<span>)</span><span>[</span>i<span>]</span><span>,</span><a target="_blank" href="http://inside-r.org/r-doc/base/diag"><span>diag</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/stats/vcov"><span>vcov</span></a><span>(</span>x<span>)</span>^<span>0.5</span><span>)</span><span>[</span>i<span>]</span><span>)</span><br><span>}</span><br>pdfsim &lt;- <a target="_blank" href="http://inside-r.org/r-doc/stats/rnorm"><span>rnorm</span></a><span>(</span>sims<span>,</span><a target="_blank" href="http://inside-r.org/r-doc/grDevices/pdf"><span>pdf</span></a><span>,</span>pdfsd<span>)</span><br>sim.se &lt;- pdfsim*sim<br>res &lt;- <a target="_blank" href="http://inside-r.org/r-doc/base/cbind"><span>cbind</span></a><span>(</span>marginal.effects<span>,</span><a target="_blank" href="http://inside-r.org/r-doc/stats/sd"><span>sd</span></a><span>(</span>sim.se<span>)</span><span>)</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/colnames"><span>colnames</span></a><span>(</span>res<span>)</span><span>[</span><span>2</span><span>]</span> &lt;- <span>&quot;standard.error&quot;</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/ifelse"><span>ifelse</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/names"><span>names</span></a><span>(</span>x$coefficients<span>[</span><span>1</span><span>]</span><span>)</span>==<span>&quot;(Intercept)&quot;</span><span>,</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/return"><span>return</span></a><span>(</span>res<span>[</span><span>2</span>:<a target="_blank" href="http://inside-r.org/r-doc/base/nrow"><span>nrow</span></a><span>(</span>res<span>)</span><span>,</span><span>]</span><span>)</span><span>,</span><a target="_blank" href="http://inside-r.org/r-doc/base/return"><span>return</span></a><span>(</span>res<span>)</span><span>)</span><br><span>}</span><br> <br><span># marginal effects from logit</span><br>mfx<span>(</span>mylogit<span>)</span><br> <br> <br><span>### code it yourself for marginal effects at the mean</span><br> <br><a target="_blank" href="http://inside-r.org/r-doc/base/summary"><span>summary</span></a><span>(</span>dat1<span>)</span><br> <br>b0 &lt;-  <span>5.92972</span>   <span># estimated intercept from logit</span><br>b1 &lt;-  -<span>0.14099</span>  <span># estimated b from logit</span><br> <br>xvar &lt;- <span>39.5</span>   <span># reference value (i.e. mean)for explanatory variable</span><br>d &lt;- <span>.0001</span>     <span># incremental change in x</span><br> <br>xbi &lt;- <span>(</span>xvar + d<span>)</span>*b1 + b0<br>xbj &lt;- <span>(</span>xvar - d<span>)</span>*b1 + b0<br>meff &lt;- <span>(</span><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>xbi<span>)</span>/<span>(</span><span>1</span>+<a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>xbi<span>)</span><span>)</span><span>)</span>-<span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>xbj<span>)</span>/<span>(</span><span>1</span>+<a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>xbj<span>)</span><span>)</span><span>)</span><span>)</span>/<span>(</span>d*<span>2</span><span>)</span> <span>;</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/print"><span>print</span></a><span>(</span>meff<span>)</span><br> <br> <br><span>### a different perhaps easier formulation for me at the mean</span><br> <br>XB &lt;- xvar*b1 + b0 <span># this could be expanded for multiple b's or x's</span><br>meffx &lt;- <span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>XB<span>)</span>/<span>(</span><span>(</span><span>1</span>+<a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>XB<span>)</span><span>)</span>^<span>2</span><span>)</span><span>)</span>*b1<br><a target="_blank" href="http://inside-r.org/r-doc/base/print"><span>print</span></a><span>(</span>meffx<span>)</span><br> <br> <br><span>### averaging the meff for the whole data set</span><br> <br>dat1$XB &lt;- dat1$age*b1 + b0<br> <br>meffx &lt;- <span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>dat1$XB<span>)</span>/<span>(</span><span>(</span><span>1</span>+<a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>dat1$XB<span>)</span><span>)</span>^<span>2</span><span>)</span><span>)</span>*b1<br><a target="_blank" href="http://inside-r.org/r-doc/base/summary"><span>summary</span></a><span>(</span>meffx<span>)</span> <span># get mean</span><br> <br><span>#### marginal effects from linear model</span><br> <br>lpm &lt;- <a target="_blank" href="http://inside-r.org/r-doc/stats/lm"><span>lm</span></a><span>(</span>dat1$participate~dat1$age<span>)</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/summary"><span>summary</span></a><span>(</span>lpm<span>)</span><br> <br><span>#---------------------------------------------------</span><br><span>#</span><br><span>#</span><br><span># multivariable case</span><br><span>#</span><br><span>#</span><br><span>#---------------------------------------------------</span><br> <br>dat2 &lt;- <a target="_blank" href="http://inside-r.org/r-doc/utils/read.csv"><span>read.csv</span></a><span>(</span><span>&quot;http://www.ats.ucla.edu/stat/data/binary.csv&quot;</span><span>)</span><br> <br><a target="_blank" href="http://inside-r.org/r-doc/utils/head"><span>head</span></a><span>(</span>dat2<span>)</span> <br> <br><a target="_blank" href="http://inside-r.org/r-doc/base/summary"><span>summary</span></a><span>(</span>dat2<span>)</span> <span># summary stats</span><br> <br><span>#### run logistic regression model</span><br> <br>mylogit &lt;- <a target="_blank" href="http://inside-r.org/r-doc/stats/glm"><span>glm</span></a><span>(</span><a target="_blank" href="http://inside-r.org/packages/cran/AdMit">admit</a> ~ gre + gpa<span>,</span> <a target="_blank" href="http://inside-r.org/r-doc/utils/data"><span>data</span></a> = dat2<span>,</span> <a target="_blank" href="http://inside-r.org/r-doc/stats/family"><span>family</span></a> = <span>&quot;binomial&quot;</span><span>)</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/summary"><span>summary</span></a><span>(</span>mylogit<span>)</span><br> <br><a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/cbind"><span>cbind</span></a><span>(</span>OR = <a target="_blank" href="http://inside-r.org/r-doc/stats/coef"><span>coef</span></a><span>(</span>mylogit<span>)</span><span>,</span> <a target="_blank" href="http://inside-r.org/r-doc/stats/confint"><span>confint</span></a><span>(</span>mylogit<span>)</span><span>)</span><span>)</span> <span># get odds ratios</span><br> <br><span># marginal effects from logit</span><br>mfx<span>(</span>mylogit<span>)</span><br> <br> <br><span>### code it yourself for marginal effects at the mean</span><br> <br><a target="_blank" href="http://inside-r.org/r-doc/base/summary"><span>summary</span></a><span>(</span>dat1<span>)</span><br> <br>b0 &lt;-  -<span>4.949378</span>    <span># estimated intercept from logit</span><br>b1 &lt;-  <span>0.002691</span>     <span># estimated b for gre</span><br>b2 &lt;-   <span>0.754687</span>    <span># estimated b for gpa</span><br> <br>x1 &lt;- <span>587</span>    <span># reference value (i.e. mean)for gre</span><br>x2 &lt;- <span>3.39</span>   <span># reference value (i.e. mean)for gre</span><br>d &lt;- <span>.0001</span>   <span># incremental change in x</span><br> <br><span># meff at means for gre</span><br>xbi &lt;- <span>(</span>x1 + d<span>)</span>*b1 + b2*x2 + b0<br>xbj &lt;- <span>(</span>x1 - d<span>)</span>*b1 + b2*x2 + b0<br>meff &lt;- <span>(</span><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>xbi<span>)</span>/<span>(</span><span>1</span>+<a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>xbi<span>)</span><span>)</span><span>)</span>-<span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>xbj<span>)</span>/<span>(</span><span>1</span>+<a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>xbj<span>)</span><span>)</span><span>)</span><span>)</span>/<span>(</span>d*<span>2</span><span>)</span> <span>;</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/print"><span>print</span></a><span>(</span>meff<span>)</span><br> <br><span># meff at means for gpa</span><br>xbi &lt;- <span>(</span>x2 + d<span>)</span>*b2 + b1*x1 + b0<br>xbj &lt;- <span>(</span>x2 - d<span>)</span>*b2 + b1*x1 + b0<br>meff &lt;- <span>(</span><span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>xbi<span>)</span>/<span>(</span><span>1</span>+<a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>xbi<span>)</span><span>)</span><span>)</span>-<span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>xbj<span>)</span>/<span>(</span><span>1</span>+<a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>xbj<span>)</span><span>)</span><span>)</span><span>)</span>/<span>(</span>d*<span>2</span><span>)</span> <span>;</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/print"><span>print</span></a><span>(</span>meff<span>)</span><br> <br> <br><span>### a different perhaps easier formulation for me at the mean</span><br> <br>XB &lt;- x1*b1 +x2*b2 + b0 <span># this could be expanded for multiple b's or x's</span><br> <br><span># meff at means for gre</span><br>meffx &lt;- <span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>XB<span>)</span>/<span>(</span><span>(</span><span>1</span>+<a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>XB<span>)</span><span>)</span>^<span>2</span><span>)</span><span>)</span>*b1<br><a target="_blank" href="http://inside-r.org/r-doc/base/print"><span>print</span></a><span>(</span>meffx<span>)</span><br> <br><span># meff at means for gpa</span><br>meffx &lt;- <span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>XB<span>)</span>/<span>(</span><span>(</span><span>1</span>+<a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>XB<span>)</span><span>)</span>^<span>2</span><span>)</span><span>)</span>*b2<br><a target="_blank" href="http://inside-r.org/r-doc/base/print"><span>print</span></a><span>(</span>meffx<span>)</span><br> <br><span>### averaging the meff for the whole data set</span><br> <br>dat2$XB &lt;- dat2$gre*b1 + dat2$gpa*b2 + b0<br> <br><span># sample avg meff for gre</span><br>meffx &lt;- <span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>dat1$XB<span>)</span>/<span>(</span><span>(</span><span>1</span>+<a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>dat1$XB<span>)</span><span>)</span>^<span>2</span><span>)</span><span>)</span>*b1<br><a target="_blank" href="http://inside-r.org/r-doc/base/summary"><span>summary</span></a><span>(</span>meffx<span>)</span> <span># get mean</span><br> <br><span># sample avg meff for gpa</span><br>meffx &lt;- <span>(</span><a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>dat1$XB<span>)</span>/<span>(</span><span>(</span><span>1</span>+<a target="_blank" href="http://inside-r.org/r-doc/base/exp"><span>exp</span></a><span>(</span>dat1$XB<span>)</span><span>)</span>^<span>2</span><span>)</span><span>)</span>*b2<br><a target="_blank" href="http://inside-r.org/r-doc/base/summary"><span>summary</span></a><span>(</span>meffx<span>)</span> <span># get mean</span><br> <br><span>#### marginal effects from linear model</span><br> <br>lpm &lt;- <a target="_blank" href="http://inside-r.org/r-doc/stats/lm"><span>lm</span></a><span>(</span><a target="_blank" href="http://inside-r.org/packages/cran/AdMit">admit</a> ~ gre + gpa<span>,</span> <a target="_blank" href="http://inside-r.org/r-doc/utils/data"><span>data</span></a> = dat2<span>)</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/summary"><span>summary</span></a><span>(</span>lpm<span>)</span></pre>
</div>
</div>
<p><a title="Created by Pretty R at inside-R.org" target="_blank" href="http://www.inside-r.org/pretty-r">Created by Pretty R at inside-R.org</a></p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="http://www.r-bloggers.com/divide-by-4-rule-for-marginal-effects/"></div></div><div><a data-url="http://www.r-bloggers.com/divide-by-4-rule-for-marginal-effects/" data-counturl="http://www.r-bloggers.com/divide-by-4-rule-for-marginal-effects/" data-count="vertical" data-text="Divide by 4 Rule for Marginal Effects" 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://econometricsense.blogspot.com/2016/05/divide-by-4-rule-for-marginal-effects.html"> Econometric Sense</a></strong>.</div>
<hr>
<a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="http://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="http://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="http://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="http://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="http://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="http://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="http://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="http://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="http://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="http://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="http://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="http://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="http://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="http://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="http://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="http://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/WhXHZos-moc"></a></div>