Here’s a simple skew normal regression model that throws a lot of divergent transaction warnings. What’s a better way to model this to avoid divergence and get consistent results?
library(sn)
n <- 500
x <- as.numeric(seq(from=1, to=n, by=1))
dAlpha <- 10
dBeta <- 2
noise <- as.numeric(rsn(length(x), xi = 0, omega = 500, alpha = 50))
y <- (dAlpha + dBeta*x) + noise
stanMod3 <- ’
data {
int<lower=0> N;
vector[N] y;
vector[N] x;
}
parameters {
real alpha;
real beta;
real<lower=0> sigma;
}
model {
target += skew_normal_lpdf(y | (alpha + beta*x), 500, 50);
}
’
fit <- stan(model_code = stanMod3, data = list(y= y, N=n, x=x))
summary(fit)