# Usage of tau in B-splines model

Hi all,

https://mc-stan.org/users/documentation/case-studies/splines_in_stan.html

which contains the following model:

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?

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

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.

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.

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


Ok, thanks for the explanation!

thanks, will have a look at the earlier examples