Documentation bug in profiling vignette?

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);
  }
')
2 Likes

Thanks, I created an issue Documentation bug in profiling vignette · Issue #1136 · stan-dev/cmdstanr · GitHub (should not take much time to fix)

2 Likes

Thanks, I was unsure about were to report it.

1 Like

Thank you! I just opened a PR to fix this: Use consistent syntax in profiling vignette by jgabry · Pull Request #1137 · stan-dev/cmdstanr · GitHub

1 Like