Page 1 of 1

Linear regression model in WinBugs with known errors

Posted: Wed Jan 14, 2015 5:45 pm
by gca12car
I have a linear regression model like this y = alpha x + gamma

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
  ....
}
where P=C^-1

Thanks in advance

Re: Linear regression model in WinBugs with known errors

Posted: Fri Jan 30, 2015 10:03 pm
by GeorgeLeckie
Dear gca12car,

I'm afraid that is the not the right forum for your query. This forum is for the runmlwin command in Stata, not the WinBUGS software. All I can suggest is that you go to the WinBUGS website and post your message there or take a look at some of the many books on WinBUGS which are available.

Sorry not to be of more help

George

Re: Linear regression model in WinBugs with known errors

Posted: Sat Jan 31, 2015 12:28 am
by GeorgeLeckie
One further thought. You can specify a limited range of models using MLwiN which allow for known measurement error in a covariate and this may be of some interest. See our MLwiN MCMC manual for further details. Note also that one can use MLwiN to generate WinBUGS code for any specified model and this may also be of some interest. Again see the MLwiN MCMC manual for further details. Best wishes. George

Re: Linear regression model in WinBugs with known errors

Posted: Sat Jan 31, 2015 4:49 am
by GeorgeLeckie