No matches for: gp_exp_quad_cov(vector, real, real)

Hi All,

Why the parser syntax error when it seems to be telling me that the argument types I’m giving are what it wants (macOS Big Sur 11.6.5 iMac, rstan 2.21.1, stan 2.21.0)? Why the distinction between `vector’ and ‘vector[ ]’? Thanks for the help. Best, Jarrett (comments stripped in Stan code below)

Stan code excerpts:

data{
…snip…
vector[Nl1] ltime1;
…snip…
}
…snip…
parameters {
real<lower=0> rDorm;
real<lower=0> rCmD;
real<lower=0> aCampus;
…snip…
}
transformed parameters{
real rCampus = rCmD + rDorm;
vector[Nl1] f1;
matrix[Nl1, Nl1] L_K;
{
matrix[Nl1, Nl1] K;
K = gp_exp_quad_cov(ltime1, aCampus, rCampus);
// diagonal elements
for (n in 1:Nl1) {
K[n, n] = K[n, n] + delta;
}
L_K = cholesky_decompose(K);
f1 = L_K * eta1 + loadmean;
}
}
…snip…

In R:

library(rstan, quietly=TRUE)
rstan (Version 2.21.1, GitRev: 2e1f913d3ca3)
…snip…
COVICoMo.stanc<- stanc(file="./COVICoMoNEW.stan")
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
No matches for:

gp_exp_quad_cov(vector, real, real)

Available argument signatures for gp_exp_quad_cov:

gp_exp_quad_cov(real[ ], real, real)
gp_exp_quad_cov(real[ ], real[ ], real, real)
gp_exp_quad_cov(vector[ ], real, real)
gp_exp_quad_cov(vector[ ], vector[ ], real, real)
gp_exp_quad_cov(vector[ ], real, real[ ])
gp_exp_quad_cov(vector[ ], vector[ ], real, real[ ])

error in ‘model1445b75cec0ce_COVICoMoNEW’ at line 94, column 49

92:     // ltime2. (Or combine obs/pred times and obtain predictions here.)
93:     matrix[Nl1, Nl1] K;
94:     K = gp_exp_quad_cov(ltime1, aCampus, rCampus);
                                                    ^
95:     // diagonal elements

Error in stanc(file = “./COVICoMoNEW.stan”) :
failed to parse Stan model ‘COVICoMoNEW’ due to the above error.

stan_version()
[1] “2.21.0”

Hi, the difference is that a vector is a regular vector and vector[] is an array of vectors.
Much like real is a scalar while real[] is an array of reals.

I understand that I can generally define a vector or an array of vectors, but I, in my code, according to my understanding (https://mc-stan.org/docs/2_29/reference-manual-2_29.pdf#page27) and experience for defining a vector, I have a vector, not an array of vectors, and the parser says it expects a vector, yet I get the parser error.

In your code your input is a vector but the parser is expecting an array of vectors.

This is another way of writing the allowed signatures:

gp_exp_quad_cov(array[] real, real, real) => matrix
gp_exp_quad_cov(array[] real, array[] real, real, real) => matrix
gp_exp_quad_cov(array[] vector, real, real) => matrix
gp_exp_quad_cov(array[] vector, real, array[] real) => matrix
gp_exp_quad_cov(array[] vector, array[] vector, real, real) => matrix
gp_exp_quad_cov(array[] vector, array[] vector, real, array[] real) => matrix

I seem to recall the parser not accepting the array [] real definition. I’ll try modifying to an array of vectors to see what happens…

…the parser did not like the change from vector to array of vectors. Not sure what to do now.

COVICoMo.stanc<- stanc(file="./COVICoMoNEW.stan")
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
error in ‘model1445b3211f3e6_COVICoMoNEW’ at line 36, column 2

34: int<lower=1> Nl1;
35: vector[Nl1] load1;
36: array[1] vector[Nl1] ltime1;
^
37: int<lower=1> Nl2;

PARSER EXPECTED: <one of the following:
a variable declaration, beginning with type,
(int, real, vector, row_vector, matrix, unit_vector,
simplex, ordered, positive_ordered,
corr_matrix, cov_matrix,
cholesky_corr, cholesky_cov
or ‘}’ to close variable declarations>
Error in stanc(file = “./COVICoMoNEW.stan”) :
failed to parse Stan model ‘COVICoMoNEW’ due to the above error.