# Estimating student-t degrees of freedom?

Hi everyone,

I’m having troubles estimating the degrees of freedom when I use a student-t distribution for my prior. I can estimate the model without any problems if I set the degrees of freedom to 4, but if I try to estimate them my effective sample side end up being extremely small (n_eff=2 if iter = 1000).

Is there something like the matt trick that could help me estimate this parameter. Or is there something else that I’m missing that could make this parameter impossible to estimate with my data?

This is my stan code:

``````data {
int<lower=0> J;             //
real y[J];                  // estimated  effect
int<lower=0> n[J];          //
}

parameters {
real mu;                    //
real<lower=0> nu;           //
real<lower=0> tau;          //
vector[J] eta;
real<lower=0> gamma;          // degrees of freedom
}

transformed parameters {
vector[J] theta;
vector<lower = 0>[J] sigma;
theta = mu + tau * eta;
for (j in 1:J) sigma[j] = nu/sqrt(n[j]);
}

model {
eta ~ student_t(gamma, 0, 1);
y ~ normal(theta, sigma);
}
``````

Thanks for the help!

It’s likely that you need a prior and constraint for gamma. I guess you now get gamma values < 1, which makes student_t to have thicker tails than Cauchy which usually means problems for MCMC.

2 Likes

Thanks, that did the trick :-)