<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Marginal Effects on Volundarhus</title><link>http://www.volundarhus.com/tags/marginal-effects/</link><description>Recent content in Marginal Effects on Volundarhus</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sun, 31 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="http://www.volundarhus.com/tags/marginal-effects/index.xml" rel="self" type="application/rss+xml"/><item><title>pymargins: A Ground-Up Redesign of Marginal Effects for Python</title><link>http://www.volundarhus.com/posts/pymargins_package/</link><pubDate>Sun, 31 May 2026 00:00:00 +0000</pubDate><guid>http://www.volundarhus.com/posts/pymargins_package/</guid><description>&lt;p&gt;A while back I wrote about &lt;a href="http://www.volundarhus.com/posts/smmargins/" &gt;marginal effects for StatsModels&lt;/a&gt;&#10;and then &lt;a href="http://www.volundarhus.com/posts/smmargins_package/" &gt;released that work as &lt;strong&gt;smmargins&lt;/strong&gt;&lt;/a&gt;,&#10;a package that brought Stata-style &lt;code&gt;margins&lt;/code&gt; to the StatsModels&#10;ecosystem. This post is about its successor, &lt;strong&gt;pymargins&lt;/strong&gt;, which is&#10;not a new version of smmargins but a complete, ground-up redesign.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pip install pymargins&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="where-this-came-from"&gt;&#10; Where this came from&#10; &lt;a class="heading-link" href="#where-this-came-from"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;smmargins started as research code. I was doing population-study work&#10;at UCSF, and the recurring need was to turn fitted models into&#10;quantities people could actually act on: a risk difference in&#10;percentage points, an adjusted prediction at a representative patient&#10;profile, a subgroup average marginal effect. StatsModels'&#10;&lt;code&gt;get_margeff()&lt;/code&gt; covered a sliver of that, so I kept accreting helpers&#10;until the helpers were the size of a package. smmargins was me carving&#10;the useful parts out of that research code and giving them a public&#10;API.&lt;/p&gt;</description></item><item><title>Introducing smmargins: Stata-Style Margins for Python StatsModels</title><link>http://www.volundarhus.com/posts/smmargins_package/</link><pubDate>Sun, 03 May 2026 21:46:31 -0700</pubDate><guid>http://www.volundarhus.com/posts/smmargins_package/</guid><description>A new Python package bringing Stata&amp;rsquo;s margins command to the StatsModels ecosystem.</description></item><item><title>Marginal Effects for StatsModels: A Stata-style `margins` in Python</title><link>http://www.volundarhus.com/posts/smmargins/</link><pubDate>Wed, 22 Apr 2026 00:00:00 +0000</pubDate><guid>http://www.volundarhus.com/posts/smmargins/</guid><description>&lt;blockquote&gt;&#10;&lt;p&gt;&lt;strong&gt;Archived.&lt;/strong&gt; The module described here grew into the &lt;strong&gt;smmargins&lt;/strong&gt;&#10;package, which has since been superseded by &lt;strong&gt;pymargins&lt;/strong&gt;, a&#10;ground-up redesign with JAX-native autodiff, a κ curvature diagnostic,&#10;unified delta/simulation/bootstrap inference, and many more model&#10;backends. The write-up below is kept for the math and design notes,&#10;but new development happens on pymargins. See &lt;a href="http://www.volundarhus.com/posts/pymargins_package/" &gt;pymargins: A Ground-Up&#10;Redesign of Marginal Effects for Python&lt;/a&gt;.&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;If you&amp;rsquo;ve ever moved from Stata to Python and reached for &lt;code&gt;margins, dydx(*) at(age=(25 45 65))&lt;/code&gt;, you know the feeling. StatsModels has &lt;code&gt;get_margeff&lt;/code&gt;, but it&amp;rsquo;s narrow: average or at-means, continuous variables, a couple of model classes. The moment you want a marginal effect &lt;em&gt;at a specific covariate profile&lt;/em&gt;, or a discrete change for a factor, or a difference-in-differences on the probability scale of a logit, you&amp;rsquo;re on your own.&lt;/p&gt;</description></item></channel></rss>