# Advice me in Theoretical concept for GP Likelihood

Hi There,

I have a theoretical question regarding the Likelihood of GP, which now I am in dubt how stan will solve it numerically. I know that Stan will take the Log Likelihood for doing the inference. If we consider as an example the n number of observation and the fact that each data point is considered as exchangeable units in our Bayesian inference, then the concept mathematically is equivalent to assuming that θ (i.e. our hyper-parameters which in our case is Kernel parameters) are drawn from a common prior distribution with unknown parameters. Thus if we consider a simple GP resgresseion model as bellow then the full likelihood for the GP should be this:??

Could you kindly advice me to understant the core of the idea better? for now, I beleive that Stan will take the log of Normal likelihood and then do the product for all n observation. However, there is no need to add for loop in the model block as it is done by Kernel function. Or this statement is true:
" stan can consider the vectorize format like y ~ N(m,s), and for the non-vectorized format we should use for loop? If I am wrong please kindly correct me.

If y and f are vectors of length N and sigma is a scalar, then

``````y ~ normal(f, sigma)
``````

is the same as

``````for (n in 1:N) {
y[n] ~ normal(f[n], sigma)
}
``````

but if your prior and likelihood are both normal/Gaussian, then you could also integrate f out analytically and define the multivariate model directly for y (see Stan User’s guide for code examples)

1 Like