I’m trying to implement a poor man’s version of the request in this issue. Here’s my stan code:
functions{
real zeta(real s);
real power_law_lpmf(int x, real alpha){
return (-alpha * log(x) - log(zeta(alpha)) );
}
/*TODO: implement rng for prior and posterior predictive checks*/
}
data{
int<lower=0> K; // number of unique values
int values[K];
int<lower=0> frequencies[K];
}
parameters{
real <lower=1> alpha;
}
model{
for (k in 1:K) target += frequencies[k] * power_law_lpmf(values[k] | alpha);
}
And here is my R code:
plaw.model <- stan_model(file = "stan/discrete_power_law.stan", allow_undefined = TRUE,
boost_lib = "/usr/include/boost/",
includes = "/usr/include/boost/math/special_functions/zeta.hpp")
with output
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from /home/max/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/Core:392:0,
from /home/max/R/x86_64-pc-linux-gnu-library/3.5/RcppEigen/include/Eigen/Dense:1,
from /home/max/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,
from /home/max/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat/fun/Eigen_NumTraits.hpp:4,
from /home/max/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/core/matrix_vari.hpp:4,
from /home/max/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/core.hpp:14,
from /home/max/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math/rev/mat.hpp:4,
from /home/max/R/x86_64-pc-linux-gnu-library/3.5/StanHeaders/include/stan/math.hpp:4,
from /home/max
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command '/usr/local/lib/R/bin/R CMD SHLIB file2c8d1ddbd8bf.cpp 2> file2c8d1ddbd8bf.cpp.err.txt' had status 1
Error in sink(type = "output") : invalid connection
I strongly suspect this might be related to this bug, but how do I solve it?
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so
locale:
[1] LC_CTYPE=pt_BR.UTF-8 LC_NUMERIC=C LC_TIME=pt_BR.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=pt_BR.UTF-8 LC_MESSAGES=en_GB.UTF-8 LC_PAPER=pt_BR.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=pt_BR.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rstan_2.18.2 StanHeaders_2.18.0-1 ggplot2_3.1.0 poweRlaw_0.70.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 pillar_1.3.1 compiler_3.5.1 plyr_1.8.4 bindr_0.1.1 prettyunits_1.0.2
[7] tools_3.5.1 pkgbuild_1.0.2 tibble_1.4.2 gtable_0.2.0 pkgconfig_2.0.2 rlang_0.3.0.1
[13] cli_1.0.1 rstudioapi_0.8 yaml_2.2.0 parallel_3.5.1 loo_2.0.0 bindrcpp_0.2.2
[19] gridExtra_2.3 withr_2.1.2 dplyr_0.7.8 stats4_3.5.1 grid_3.5.1 tidyselect_0.2.5
[25] glue_1.3.0 inline_0.3.15 R6_2.3.0 processx_3.2.1 VGAM_1.0-6 purrr_0.2.5
[31] callr_3.1.0 magrittr_1.5 matrixStats_0.54.0 scales_1.0.0 ps_1.2.1 splines_3.5.1
[37] assertthat_0.2.0 colorspace_1.3-2 lazyeval_0.2.1 munsell_0.5.0 crayon_1.3.4