@anon79882417: here’s all the stan code that i use:
data {
int<lower = 1> N;
int<lower = 1> D;
vector[D] X[N];
vector[N] Y;
}
transformed data {
vector[N] Y_log = log(Y);
vector[N] mu = rep_vector(0, N);
}
parameters {
real<lower = 0> magnitude;
real<lower = 0> length_scale;
real<lower = 0> eta;
}
transformed parameters {
matrix[N, N] L_K;
{
matrix[N, N] K;
K = cov_exp_quad(X, magnitude, length_scale);
K = K + diag_matrix(rep_vector(square(eta), N));
L_K = cholesky_decompose(K);
}
}
model {
magnitude ~ normal(0, 2);
length_scale ~ inv_gamma(5, 5);
Y_log ~ multi_normal_cholesky(mu, L_K);
}
short long story: I am trying to reproduce the two-dimensional krigging on the mesue dataset, so in this case D=2 and Y corresposds to the zinc
varable, that I log-transformed (see transformed data block).
cmdstan (v. 2.18.0) gives me no error: just one warning:
Model name=GP_model
Input file=/home/fabio/Documents/STAN/spatial/GP.stan
Output file=/home/fabio/Documents/STAN/spatial/GP.hpp
DIAGNOSTIC(S) FROM PARSER:
Warning: left-hand side variable (name=K) occurs on right-hand side of assignment, causing inefficient deep copy to avoid aliasing.
Compiling pre-compiled header
g++ -Wall -I . -isystem stan/lib/stan_math/lib/eigen_3.3.3 -isystem stan/lib/stan_math/lib/boost_1.66.0 -isystem stan/lib/stan_math/lib/sundials_3.1.0/include -std=c++1y -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -Wno-unused-function -Wno-uninitialized -I src -isystem stan/src -isystem stan/lib/stan_math/ -DFUSION_MAX_VECTOR_SIZE=12 -Wno-unused-local-typedefs -DEIGEN_NO_DEBUG -DNO_FPRINTF_OUTPUT -pipe -c -O3 stan/src/stan/model/model_header.hpp -o stan/src/stan/model/model_header.hpp.gch
--- Linking C++ model ---
g++ -Wall -I . -isystem stan/lib/stan_math/lib/eigen_3.3.3 -isystem stan/lib/stan_math/lib/boost_1.66.0 -isystem stan/lib/stan_math/lib/sundials_3.1.0/include -std=c++1y -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -Wno-unused-function -Wno-uninitialized -I src -isystem stan/src -isystem stan/lib/stan_math/ -DFUSION_MAX_VECTOR_SIZE=12 -Wno-unused-local-typedefs -DEIGEN_NO_DEBUG -DNO_FPRINTF_OUTPUT -pipe src/cmdstan/main.cpp -O3 -o /home/fabio/Documents/STAN/spatial/GP -include /home/fabio/Documents/STAN/spatial/GP.hpp stan/lib/stan_math/lib/sundials_3.1.0/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_3.1.0/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_3.1.0/lib/libsundials_idas.a
with the fopllowing output that I just have to understand:
mean se_mean sd 2.5% 25% 50%
magnitude 1.369176 0.12199123 1.0094181 0.05219338 0.5674067 1.189485
length_scale 1.323135 0.04959016 0.7037901 0.52565260 0.8159852 1.157775
eta 5.725117 0.06227755 0.4925067 4.46203250 5.4712100 5.761075
75% 97.5% n_eff Rhat
magnitude 2.045213 3.687646 68.46758 1.0221040
length_scale 1.596740 3.024755 201.41658 0.9982247
eta 6.035350 6.610091 62.54049 1.0115286