# Offset multiplier syntax sampling behavior

**URL:** https://discourse.mc-stan.org/t/offset-multiplier-syntax-sampling-behavior/25669
**Category:** Modeling
**Created:** [December 13, 2021, 1:12pm UTC](https://discourse.mc-stan.org/t/offset-multiplier-syntax-sampling-behavior/25669 "2021-12-13T13:12:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![daniel\_h](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/daniel_h/32/3876_2.png) [@daniel\_h](https://discourse.mc-stan.org/u/daniel_h)
#### Post date: [December 13, 2021, 1:12pm UTC](https://discourse.mc-stan.org/t/offset-multiplier-syntax-sampling-behavior/25669/1 "2021-12-13T13:12:57Z")

</div>

I’m working a model with hierarchical intercepts and slopes.  
When specifying the non-centered parameterization using offset and multiplier syntax like this I get poor sampling behavior:

```stan
parameters {
    real mu_a;
    real mu_b;
    real<lower=0> sigma_a;
    real<lower=0> sigma_b;
    vector<offset=mu_a, multiplier=sigma_a>[N] a;
    vector<offset=mu_b, multiplier=sigma_b>[N] b;
    ...
}

model {
    a ~ normal(mu_a, sigma_b);
    b ~ normal(mu_b, sigma_b);

    mu_a ~ normal(3, 0.04);
    sigma_a ~ std_normal();

    mu_b ~ normal(1, 0.01);
    sigma_b ~ std_normal();
    ...
}

```

However, when expressing `a` and `b` as transformed parameters like this, everything works fine:

```stan
parameters {
    real mu_a;
    real mu_b;
    real<lower=0> sigma_a;
    real<lower=0> sigma_b;
    vector[N] a_raw;
    vector[N] b_raw;
    ...
}

transformed parameters {
    vector[N] a = (a_raw + mu_a) * sigma_a;
    vector[N] b = (b_raw + mu_b) * sigma_b;
}

model {
    a_raw ~ std_normal();
    b_raw ~ std_normal();

    mu_a ~ normal(3, 0.04);
    sigma_a ~ std_normal();

    mu_b ~ normal(1, 0.01);
    sigma_b ~ std_normal();
    ...
}

```

I realize this is not much to work with, but does someone have any pointers of what may be going on here? Is there something going on “under the hood” that may explain these differences in sampling behavior?

---

<div class="post-metadata">

### Author: ![jsocolar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jsocolar/32/2486_2.png) [@jsocolar](https://discourse.mc-stan.org/u/jsocolar)
#### Post date: [December 13, 2021, 2:59pm UTC](https://discourse.mc-stan.org/t/offset-multiplier-syntax-sampling-behavior/25669/2 "2021-12-13T14:59:16Z")

</div>

In your manual noncentering, you multiply the means (as well as the unscaled offsets) by the sd. The sd should just multiply the unscaled offsets.

---

<div class="post-metadata">

### Author: ![daniel\_h](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/daniel_h/32/3876_2.png) [@daniel\_h](https://discourse.mc-stan.org/u/daniel_h)
#### Post date: [December 13, 2021, 3:13pm UTC](https://discourse.mc-stan.org/t/offset-multiplier-syntax-sampling-behavior/25669/3 "2021-12-13T15:13:51Z")

</div>

Oops! That was way more obvious than expected. Thank you very much!!
