Long time lurker, first time poster. All the normal disclaimers - I looked around to see if I could find something similar and didn’t, so apologies if I missed another post, or famous blog entry, or even something in the Stan manual.
But folks, this is vexing me.
I was working with someone new to Stan on a model and I saw them write something like this in the model block:
alpha + beta * x ~ normal(y, sigma);
And of course, that stood out to me as obviously “wrong.” But here’s the thing -
stan_mdl1.csv (3.7 KB)
I ran it both ways on some simulated data, and it … works?
Model 1: The Right Way
Here’s the model from the guide.
data {
int N;
vector[N] y;
vector[N] x;
}
parameters {
real alpha;
real beta;
real<lower = 0> sigma;
}
model {
y ~ normal(alpha + beta * x, sigma);
}
Model 2: The Wrong Way?
data {
int N;
vector[N] y;
vector[N] x;
}
parameters {
real alpha;
real beta;
real<lower=0> sigma;
}
model {
alpha + beta * x ~ normal(y, sigma);
}
Now Model 2 kicks the warning about non-linear transforms. But I know this isn’t (or I could provide a Jacobian if it was!) .
And the punch line is, the estimates from both models are nearly identical.
So, here are my questions:
1a.) Is there a good reason to prefer Model 1 over Model 2?
1b.) Would we say that Model 2 is ‘using data (y) in the prior (for alpha and beta)’ and that’s what’s ultimately wrong about it? The usual complaint about doing that is we are ‘using the data twice’ and I don’t think that’s happening here?
2.) Is this a trick of a simplified setting (linear, normal, ect.)?
some related reading for the interested:
Yes, you can include prior information on quantities of interest, not just on parameters in your model
I’m not 100% sure this is exactly the same situation, but I mean you could say alpha + beta * x is, in fact, a quantity of interest!
Thanks in advance for your thoughts