Linear regression model in WinBugs with known errors

Welcome to the forum for runmlwin users. Feel free to post your question about runmlwin here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Go to runmlwin: Running MLwiN from within Stata >> http://www.bristol.ac.uk/cmm/software/runmlwin/
Post Reply
gca12car
Posts: 1
Joined: Wed Jan 14, 2015 5:27 pm

Linear regression model in WinBugs with known errors

Post 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
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Linear regression model in WinBugs with known errors

Post 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
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Linear regression model in WinBugs with known errors

Post 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
Post Reply