# How to specify exposure / offset in a Bambi model?

**URL:** <https://discourse.pymc.io/t/how-to-specify-exposure-offset-in-a-bambi-model/13667>\
**Category:** version agnostic\
**Tags:** bambi\
**Created:** [January 23, 2024, 8:27pm UTC](https://discourse.pymc.io/t/how-to-specify-exposure-offset-in-a-bambi-model/13667 "2024-01-23T20:27:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrEntropy](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/drentropy/32/4747_2.png) [@DrEntropy](https://discourse.pymc.io/u/DrEntropy)\
**Post date:** [January 23, 2024, 8:27pm UTC](https://discourse.pymc.io/t/how-to-specify-exposure-offset-in-a-bambi-model/13667/1 "2024-01-23T20:27:08Z")

</div>

When fitting a poisson regression in statsmodels I can specify an offset (or exposure) like this:

```auto
smf.poissionl(formula='y ~ x',
                             exposure = data["bin_width"],
                             data = data)

```

Is there a way to do this in Bambi, or do I just need to manually write this in PYMC?

---

<div class="post-metadata">

**Author:** ![tcapretto](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/tcapretto/32/4902_2.png) [@tcapretto](https://discourse.pymc.io/u/tcapretto)\
**Post date:** [January 23, 2024, 10:20pm UTC](https://discourse.pymc.io/t/how-to-specify-exposure-offset-in-a-bambi-model/13667/2 "2024-01-23T22:20:05Z")

</div>

Hi there!

You can do

```python
bmb.Model("y ~ x + offset(log(bin_width))", data, family="poisson", link="log")

```

---

<div class="post-metadata">

**Author:** ![DrEntropy](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/drentropy/32/4747_2.png) [@DrEntropy](https://discourse.pymc.io/u/DrEntropy)\
**Post date:** [January 23, 2024, 10:42pm UTC](https://discourse.pymc.io/t/how-to-specify-exposure-offset-in-a-bambi-model/13667/3 "2024-01-23T22:42:00Z")

</div>

Oh, just like in R ! Is this documented somewhere?

---

<div class="post-metadata">

**Author:** ![tcapretto](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/tcapretto/32/4902_2.png) [@tcapretto](https://discourse.pymc.io/u/tcapretto)\
**Post date:** [January 24, 2024, 1:39pm UTC](https://discourse.pymc.io/t/how-to-specify-exposure-offset-in-a-bambi-model/13667/4 "2024-01-24T13:39:33Z")

</div>

Unfortunately, nope. It’s just in the tests.

> <https://github.com/bambinos/bambi/blob/9a1387a73c4477a8440d96f489d070c1344b174e/tests/test_models.py#L1293-L1314>

If you have any example you’d like to contribute, it will be very welcomed 🙂

---

<div class="post-metadata">

**Author:** ![DrEntropy](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/drentropy/32/4747_2.png) [@DrEntropy](https://discourse.pymc.io/u/DrEntropy)\
**Post date:** [January 30, 2024, 11:27pm UTC](https://discourse.pymc.io/t/how-to-specify-exposure-offset-in-a-bambi-model/13667/5 "2024-01-30T23:27:49Z")

</div>

My plan is to reproduce [Estimating Generalized Linear Models for Count Data with rstanarm • rstanarm (mc-stan.org)](https://mc-stan.org/rstanarm/articles/count.html) for Bambi.

Cheers!
