The Stan Math Library is a C++ template library for automatic differentiation of any order using forward, reverse, and mixed modes. It includes a range of built-in functions for probabilistic modeling, linear algebra, and equation solving.
When X has 0 columns, beta has 0 elements, and alpha has 1 element functions like bernoulli_logit_glm_lpmf (I've checked poisson too but not others yet) ignore alpha and return 0, that is,
bernoulli_logit_glm_lpmf(y | X, alpha, beta) = 0
but it should take into account alpha.
I noticed this problem because of https://github.com/stan-dev/rstanarm/issues/396, where models with only an intercept give the wrong inferences. Turning off using the compound glm functions (bernoulli_logit_glm_lpmf, poisson_log_glm_lpmf) fixes the problem. Below is an example Stan program illustrating the problem.
Example
If I run the following Stan program:
data {
int<lower=0> N;
int<lower=0,upper=1> y[N];
}
transformed data {
matrix[N, 0] X; // 0 columns
}
parameters {
real alpha;
vector[0] beta; // 0 elements
}
model {
alpha ~ normal(5, 10);
target += bernoulli_logit_glm_lpmf(y | X, alpha, beta);
}
generated quantities {
real test_lpmf = bernoulli_logit_glm_lpmf(y | X, alpha, beta);
}
then test_lpmf always has the value 0.0e+00 (i.e., 0) but it shouldn't be zero due to alpha. I have also tested the poisson case and the same problem occurs.
Expected Output
It should take alpha into account when calculating the lpmf.
Description
When
X
has0
columns,beta
has0
elements, and alpha has1
element functions likebernoulli_logit_glm_lpmf
(I've checked poisson too but not others yet) ignorealpha
and return0
, that is,bernoulli_logit_glm_lpmf(y | X, alpha, beta) = 0
but it should take into account
alpha
.I noticed this problem because of https://github.com/stan-dev/rstanarm/issues/396, where models with only an intercept give the wrong inferences. Turning off using the compound glm functions (bernoulli_logit_glm_lpmf, poisson_log_glm_lpmf) fixes the problem. Below is an example Stan program illustrating the problem.
Example
If I run the following Stan program:
then
test_lpmf
always has the value 0.0e+00 (i.e., 0) but it shouldn't be zero due toalpha
. I have also tested the poisson case and the same problem occurs.Expected Output
It should take
alpha
into account when calculating thelpmf
.Current Version:
v2.20.0 (via CmdStan 2.20.0)