/********************************************************************** * t-distribution model with known degrees of freedom * introduce a latent variable z * Peng Zeng @ Auburn University * 2025-09-17 * * model: * y ~ t(df, mu, sigma) * equivalent model with a latent vriable z * y ~ normal(mu, sigma / sqrt(z)) * z ~ gamma(df/2, df/2) * prior: * f(mu, sigma) ~ 1 / sigma **********************************************************************/ data { int n; // sample size real y[n]; // observations real df; // degrees of freedom } parameters { real mu; // mean real sigma; // standard deviation vector[n] z; } model { y ~ normal(mu, sigma ./ sqrt(z)); z ~ gamma(df/2, df/2); target += -log(sigma); // noninformative prior } /********************************************************************** * THE END **********************************************************************/