However, individual observations (y0,x0) are subjected to errors y0 = y + eyy and x0 = x + exx . Moreover the errors on the dependent and independent variables are correlated. The covariance matrix is C and its elements (exx,exy,eyx,eyy) can be modelled by normal distributions. I would like to use WinBugs to calculate the posterior distributions on alpha and gamma.
With the above premise I can write the likelihood function as a bivariate normal but I am struggling to implement it. My question is how can I write the likelihood function in the Bugs model?
Below is what I wrote but I think its not correct and also it does not work (error: mean of multivariate normal d[1,1] must have same number of components as d[1,1])
Code: Select all
#Model
model <- function(){
#Likelihood
for(i in 1:n){
d[i,1] <- x[i]
d[i,2] <- y[i]
d[i,1:2] ~ dmnorm(mu[,],P[,])
}
#Regression formula
for(i in 1:n){
mu[1,i] <- x[i]
mu[2,i] <- alpha + gamma * x[i]
}
#Priors for the regression parameters
....
}
Thanks in advance