I am using rstan (downloaded this week) to fit a toy data set with 200 rows, three predictors and a response generated from R’s rpois function. I gave the predictors coefficients of 0.3, -0.15, and 0.2 and there is an intercept of 1.4 I fit the data with the model below using either poisson_log or poisson_log_glm. The poisson_log version reports a Total time of 0.5s, Rhats of 1.000 and neff of 2000 to 4000. The version using poisson_log_glm reports a Total time of 11s, Rhats > 140, neff of 2 and a warning that “There were 3997 transitions after warmup that exceeded the maximum treedepth.” The treedepth limit was set to 10. Increasing the max_treedepth to 15 results in a similar warning after a longer run time. The treedepth in the poisson_log version does not exceed 5.
I strongly suspect I am doing something very silly but I cannot see it. Any ideas why the performance is so different?
In case it matters, my R version and system are:
R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18.3
data {
int N; //number obs
int K; //number of columns in the model matrix
int y[N]; //response
matrix[N,K] X;
}
parameters {
real alpha;
vector[K] beta; //the regression parameters
}
model {
alpha ~ normal(0,1.5);
beta ~ normal(0,1);
//y ~ poisson_log(alpha + X * beta); //version 1
y ~ poisson_log_glm(X, alpha, beta); //version 2
}