Hello,
I would like to use the built-in gp_exp_cov
function, to define a gaussian process prior for points in 2D space, as I think it’s faster than what I wrote. I think that the way that I am passing the coordinates to the function however is calculating the element-wise distance(x^2-y^2) rather than the Euclidian distance for the coordinates vector.
However, if I pass just the full vector (single argument, coords
), the matrix becomes non-symmetric.
Could someone suggest how to use this built in function for spatial models where I have a 2d vector of coordinates and want to compute the euclidian distance?
A minimal example:
data{
int<lower=0> n;
array[s] vector[2] coords;
}
parameters{
real sigma2;
real rho;
vector[n] z_eta;
}
transformed parameters{
matrix[n,n] SIGMA;
vector[n] eta;
LS = cholesky_decompose(SIGMA)
eta = LS*z_eta
}
model{
sigma2 ~ inv_gamma();
rho ~ gamma();
z_eta ~ std_normal();
}
Thank you!!