I think I stumbled upon a typo in a vignette.
Profiling Stan programs with CmdStanR • cmdstanr
The original example stan code defined in section “Adding profiling statements to a Stan program” seems to change in the second code-block into the optimized model used as proof of concept in the later section “Comparing to a faster version of the model”.
“Adding profiling statements to a Stan program” block 2 reads
profile("priors") {
target += std_normal_lpdf(beta);
target += std_normal_lpdf(alpha);
}
profile("likelihood") {
target += bernoulli_logit_lpmf(y | X * beta + alpha);
}
I think should be something like this:
profile("priors") {
beta ~ std_normal();
alpha ~ std_normal();
}
profile("likelihood") {
y ~ bernoulli_logit(X * beta + alpha);
}
“Adding profiling statements to a Stan program” block 3 is
profiling_bernoulli_logit <- write_stan_file('
data {
int<lower=1> k;
int<lower=0> n;
matrix[n, k] X;
array[n] int y;
}
parameters {
vector[k] beta;
real alpha;
}
model {
profile("priors") {
target += std_normal_lpdf(beta);
target += std_normal_lpdf(alpha);
}
profile("likelihood") {
target += bernoulli_logit_lpmf(y | X * beta + alpha);
}
}
')
I think should be something like:
profiling_bernoulli_logit <- write_stan_file('
data {
int<lower=1> k;
int<lower=0> n;
matrix[n, k] X;
array[n] int y;
}
parameters {
vector[k] beta;
real alpha;
}
model {
profile("priors") {
beta ~ std_normal();
alpha ~ std_normal();
}
profile("likelihood") {
y ~ bernoulli_logit(X * beta + alpha);
}
')