I see - how about ‘Not used in the density calculation’? It’s checking specifically whether its value affects target.
Yeah. The location printing is actually some older code that could use some love.
Updated the wording on the last version.
That should not give a false positive, it can find that a prior was given via a transformation.
That’s fair. I’d be in favor of leaving the manual section in though, since it’s not an obvious thing (to me).
Agreed. Maybe ‘assigned’?
Exactly, the analysis is conservative.
Yeah, I agree it makes sense not to introduce the new term hard constraint, lower and upper would be probably be better. (By the way, a lot of the language is copied from this page: Home · stan-dev/stan Wiki · GitHub)
(-1, 1) and (0, 1) are ignored, as are one sided bound
I’m remembering now that we have one in stanc3, it’s the --auto-format CLI option
So for each distribution, use the basest type signature to determine which arguments are broadcast, and warn if some argument is broadcast but the first argument isn’t?
I’m hesitant because I’m not sure if checking for broadcast arguments will generalize perfectly, and because there seem to be good uses for it. Honestly, I think that whenever implicit broadcasting is allowed there will always be subtle bugs like this.
But, if this rule would catch bugs that you see regularly with a low false-positive, I could add it in.
At least for this case, I don’t know if there are legitimate uses.
Eh it happened to me, so I’m just assuming it happens to people pretty regularly.
If this check only covered the scalar distributions it would be fine. “If left hand thing is scalar, and at least one right hand thing isn’t a scalar, spit a warning”.
bin/stanc --warn-pedantic --o=foo.hpp foo.stan
Warning:
The parameter alpha_std has 2 priors.
Warning:
The parameter beta_std has 2 priors.
Warning:
The parameter sigma_std has 2 priors.
Removing the transformed data {} block and renaming x_std -> x and y_std -> y fixes the problem as below:
data {
int<lower=0> N;
vector[N] y;
vector[N] x;
}
parameters {
real alpha_std;
real beta_std;
real<lower=0> sigma_std;
}
model {
alpha_std ~ normal(0, 10);
beta_std ~ normal(0, 10);
sigma_std ~ cauchy(0, 5);
for (n in 1:N)
y[n] ~ normal(alpha_std + beta_std * x[n], sigma_std);
}
Thanks everyone for your helpful feedback! I believe I’ve addressed all of the raised issues.
Pedantic mode has been available for comment in CmdStan for about two months and in the Stanc3 pull request for about four months. Does anyone have objections to merging this, flagged as ‘experimental’?
Here is a draft of the documentation. Happy to hear comments on that as well. @mitzimorris, I think we had a discussion a while ago about where the documentation should end up, but I can’t quite remember the conclusion. Let me know what you think.
I can’t remember the conclusion either. I think we should aim for a chapter in the Stan User’s Guide in the “Programming Techniques” section. all we need to do is advertise the Stan release where it has been made available. that will explain what Pedantic mode is. for the interfaces, the question is how to invoke it.
if docs in the User’s Guide sounds good to everyone here, I’ll file issues on the docs and interface repos.