I'm working on coding GP model in R and calculating its likelihood function.
I'm having problem to convert the equation below into R code:
I used the code below but I keep getting error message :
Error in (t(zlt - olt)) * (zlt - olt) : non-conformable arrays
my code is:
ConditionalLikelihood <- (-(N/2)) * (log(sig2e)) -(1/(2*(sig2e)))*(t(zlt -olt)) * (zlt- olt) -(sum(T*r)/2) *(log (sig2eta * SEta)) (-1/(2*(sig2e))) * (t(zlt- xb)) * 1/SEta *(zlt- xb)
I think it's related to the 2 sum signs. I couldn't find an example shows how to deal with 2 sum signs and follow their structure.
I tried to debug it part by part to check where I went wrong and every time I get to this part , I get the error:
(t(zlt -olt)) * (zlt- olt)
Any advice will be much appreciated.
Try %*% for matrix multiplication instead of *.
(t(zlt -olt)) %*% (zlt- olt)