Implementing skew-t log-likelihood

#1

Hello,
I am trying to implement univariate skew-t log-likelihood. There are some topics on this subject here in this forum and I am following the ideas I read.
Univariate skew-t pdf has the following expression an is implemented in R package “sn”:

image

I wrote this code for the function:

functions{
real skew_t_lpdf(vector x, real xi, real omega, real alpha){
vector[num_elements(x)] prob;
real lprob;
real z;
real zc;
real nu;
nu = 5;
for (i in 1:num_elements(x)){
z = (x[i]-xi)/omega;
zc = zalphasqrt((nu+1)/(nu + pow(z, 2)));
prob[i] = student_t_lpdf(x[i] | nu, xi, omega) + student_t_lcdf(zc | nu+1, 0, 1);
}
lprob = sum(prob);
return lprob;
}
}

I dropped constants and it seems to work fine with simulated data. However, if I change arguments in student_t_lpdf, everything goes wrong and estimates far from what would be expected.

Instead of using student_t_lpdf(x[i] | nu, xi, omega), I changed for student_t_lpdf(z | nu, 0, 1). I can’t understand this behavior.

Can anyone help me with this issue? Do I need to provide more code?
Thanks!

0 Likes

#2

Please use triple backticks (```) to mark the start and end of your code block to make it more readable. Note also that single backticks may be used to mark inline code in other text.

0 Likes