# TuringGLM.jl and offsets / exposure

**URL:** <https://discourse.julialang.org/t/turingglm-jl-and-offsets-exposure/129772>\
**Category:** Probabilistic Programming\
**Created:** [June 9, 2025, 8:15pm UTC](https://discourse.julialang.org/t/turingglm-jl-and-offsets-exposure/129772 "2025-06-09T20:15:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrEntropy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drentropy/32/216394_2.png) [@DrEntropy](https://discourse.julialang.org/u/DrEntropy)\
**Post date:** [June 9, 2025, 8:15pm UTC](https://discourse.julialang.org/t/turingglm-jl-and-offsets-exposure/129772/1 "2025-06-09T20:15:06Z")

</div>

The `roaches` example, [Poisson Regression · TuringGLM.jl](https://turinglang.org/TuringGLM.jl/stable/tutorials/poisson_regression/) ignores the exposure. In BRMS this is done using a formula term like this " … + offset(log(exposure))` . GLM.jl handles this with an extra argument to the call. Does TuringGLM support offsets in some way that is not obvious?

---

<div class="post-metadata">

**Author:** ![eteppo](https://avatars.discourse-cdn.com/v4/letter/e/90db22/32.png) [@eteppo](https://discourse.julialang.org/u/eteppo)\
**Post date:** [June 10, 2025, 8:31am UTC](https://discourse.julialang.org/t/turingglm-jl-and-offsets-exposure/129772/2 "2025-06-10T08:31:38Z")

</div>

Based on the [code of TuringGLM](https://github.com/TuringLang/TuringGLM.jl/blob/e9147392eccdcf8f9193b65c5ca58ba99f84f34b/src/turing_model.jl#L322C1-L329C8) it might be best to use DynamicPPL directly. I think the model that is created is:

```julia
    @model function poisson_model(
        y, X; predictors=size(X, 2), μ_X=μ_X, σ_X=σ_X, prior=prior
    )
        α ~ prior.intercept
        β ~ filldist(prior.predictors, predictors)
        y ~ arraydist(LazyArray(@~ LogPoisson.(α .+ X * β)))
        return nothing
    end

```

With default priors from the source, and if I understand the offset correctly (a fixed term directly from the data), the model should be something like:

```julia
@model function poisson_model(y, X, offset; n_predictors=size(X, 2))
    α ~ TDist(3)
    β ~ filldist(2.5*TDist(3), n_predictors)
    y ~ arraydist(LogPoisson.(α .+ X*β .+ offset))
    return nothing
end

```

Some details handled by TuringGLM remain like standardizing variables.
