Dear All,
I’m having a curious problem with fitting a very simple linear model to data with very small experimental uncertainties (erry) and an additional scatter (sigma). I feel embarrassed to post this because I thought it would be so simple, but I haven’t been able to make any headway. The sampling for this model seems to be incredibly inefficient. The example below takes several hours, mostly owing to the large treedepth. However, smaller treedepths lead to warnings and bimodal (wrong) posteriors.
I’m using rstan. The data looks like:
dlist <- list(
N=6
x=c(1.4864179, 0.6050052, 0.3305731, -0.3454066, -0.8971667, -1.1794228)
obsy=c(1.4824414, 0.6087327, 0.3342787, -0.3489581, -0.8926746, -1.1838201)
erry=c(4.136830e-07, 3.891018e-07, 4.618516e-07, 1.160271e-07, 1.045580e-04, 2.858379e-07)
)
I’m running stan with
model1d.stan <- stan(file="stantest1d.stan", data=dlist,
warmup=2000, iter=5000, chains=3, cores=3,
control=list(max_treedepth=25))
With the following stan code:
data{
int<lower=1> N;
vector[N] x;
vector[N] obsy;
vector[N] erry;
}
parameters{
real a;
real b1;
real<lower=0> sigma;
vector[N] y;
}
transformed parameters{
vector[N] mu;
for ( i in 1:N ) {
mu[i] = a + b1 * x[i];
}
}
model{
sigma ~ cauchy( 0 , 1 ); // Prior on scatter
b1 ~ normal( 0 , 1 ); // prior on slope
a ~ normal( 0 , 1 ); // prior on intercept
y ~ normal( mu , sigma );
obsy ~ normal( y , erry );
}