library(rstan)
scode <- "
data {
real<lower=1> nu;
real alpha;
}
transformed data {
real sqrt_nu = sqrt(nu);
}
parameters {
real<lower=0> V;
real Z;
}
transformed parameters {
real T = Z * sqrt(V) * sqrt_nu;
}
model {
V ~ inv_chi_square(nu);
Z ~ skew_normal(0, 1, alpha);
}
"
foo_data <- list(nu = 4, alpha = 1)
foo <- stan(model_code = scode, data = foo_data, chains = 1, iter = 4000, control=list(adapt_delta=0.8))
T <- extract(foo)$T