# Usage of tau in B-splines model

**URL:** <https://discourse.mc-stan.org/t/usage-of-tau-in-b-splines-model/32310>\
**Category:** Modeling\
**Tags:** splines, specification\
**Created:** [August 1, 2023, 9:53am UTC](https://discourse.mc-stan.org/t/usage-of-tau-in-b-splines-model/32310 "2023-08-01T09:53:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loni92](https://avatars.discourse-cdn.com/v4/letter/l/5fc32e/32.png) [@Loni92](https://discourse.mc-stan.org/u/Loni92)\
**Post date:** [August 1, 2023, 9:53am UTC](https://discourse.mc-stan.org/t/usage-of-tau-in-b-splines-model/32310/1 "2023-08-01T09:53:02Z")

</div>

Hi all,

I have what’s probably a rather basic question. I was reading this article on B-splines regression  
[https://mc-stan.org/users/documentation/case-studies/splines\_in\_stan.html](https://mc-stan.org/users/documentation/case-studies/splines_in_stan.html)

which contains the following model:

```plaintext
data { 
  int num_data; 
  int num_basis; 
  vector[num_data] Y; 
  vector[num_data] X; 
  matrix[num_basis, num_data] B; 
} 
 
parameters { 
  row_vector[num_basis] a_raw; 
  real a0; 
  real<lower=0> sigma; 
  real<lower=0> tau; 
} 
 
transformed parameters { 
  row_vector[num_basis] a; 
  vector[num_data] Y_hat; 
  a = a_raw*tau;  
  Y_hat = a0*X + to_vector(a*B); 
} 
 
model { 
  a_raw ~ normal(0, 1); 
  tau ~ cauchy(0, 1); 
  sigma ~ cauchy(0, 1); 
  Y ~ normal(Y_hat, sigma); 
} 

```

I am wondering about the `tau` parameter, is it equivalent to 1/\sigma^2 here and if so, why not use `sigma`? Or is this some naming convention that is just not obvious to me?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![dankehila](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/dankehila/32/16289_2.png) [@dankehila](https://discourse.mc-stan.org/u/dankehila)\
**Post date:** [August 1, 2023, 5:56pm UTC](https://discourse.mc-stan.org/t/usage-of-tau-in-b-splines-model/32310/2 "2023-08-01T17:56:39Z")

</div>

While you are correct that the Greek letter \tau is also used as the precision coefficient instead of standard deviation in some models, especially models based on the old JAGS parametrization, in this case \tau is the variance of the spline coefficients (like slopes for each basis) and is parametrized like a standard deviation term and not like a precision term.

To get better intuition, you can technically parametrize using `a` directly rather than `a_raw` and `tau`: you would just have

```stan
parameters{
 row_vector[num_basis] a;
...
}
transformed parameters{
...
  vector[num_data] Y_hat; 
  Y_hat = a0*X + to_vector(a*B); 
}
model {
...
a ~ normal(0,tau);
}

```

But I believe using `a_raw` and `tau` may be a more efficient way to code the model, though I would check for myself that they both give the same result for simple simulated or real datasets. The `a_raw, tau` looks to me like what’s called a non-centered parametrization, which can have advantages, for example allowing you to use the computationally-efficient `std_normal()` prior for `a_raw`, and it is possible too that `a_raw` scales better for more complex models with multiple features.

---

<div class="post-metadata">

**Author:** ![js592](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@js592](https://discourse.mc-stan.org/u/js592)\
**Post date:** [August 1, 2023, 6:07pm UTC](https://discourse.mc-stan.org/t/usage-of-tau-in-b-splines-model/32310/3 "2023-08-01T18:07:16Z")

</div>

Tau in the B-splines model is part of the random walk prior, so I think it might be parameterized that way in the earlier examples in the case study to connect to the latter smoothing. It ensures that the coefficients of _consecutive_ spline functions are relatively close to each other, enforcing smoothness.

```stan
a[i] = a[i-1] + a_raw[i]*tau; 

```

---

<div class="post-metadata">

**Author:** ![Loni92](https://avatars.discourse-cdn.com/v4/letter/l/5fc32e/32.png) [@Loni92](https://discourse.mc-stan.org/u/Loni92)\
**Post date:** [August 2, 2023, 7:34am UTC](https://discourse.mc-stan.org/t/usage-of-tau-in-b-splines-model/32310/4 "2023-08-02T07:34:34Z")

</div>

Ok, thanks for the explanation!

---

<div class="post-metadata">

**Author:** ![Loni92](https://avatars.discourse-cdn.com/v4/letter/l/5fc32e/32.png) [@Loni92](https://discourse.mc-stan.org/u/Loni92)\
**Post date:** [August 2, 2023, 7:36am UTC](https://discourse.mc-stan.org/t/usage-of-tau-in-b-splines-model/32310/5 "2023-08-02T07:36:10Z")

</div>

thanks, will have a look at the earlier examples
