 Email discussion lists for the UK Education and Research communities  ## BUGS@JISCMAIL.AC.UK

#### View:

 Message: [ First | Previous | Next | Last ] By Topic: [ First | Previous | Next | Last ] By Author: [ First | Previous | Next | Last ] Font: Proportional Font  LISTSERV Archives  BUGS Home  BUGS 2006

#### Options  Subscribe or Unsubscribe   Log In   Get Password Subject: winbugs - R question

From:  Date: Mon, 9 Oct 2006 08:23:20 +0200

Content-Type: text/plain

Parts/Attachments:  text/plain (76 lines)
 ```hi all i would like to use r and winbugs in order to undertake seemingly unrelated regression. i am using the R2WINBUGS library. i just simulated a simple example (sample size is 25) in order to get the correct code. i suspect that the problem is in my definition of the prior. it wants a multivariate node. the example could be extended by including more than 1 X variable in the system of equations. how can one specify the following prior: the sum of the estimated betas (including the constant) is normal "a" and variance "b" say? my code is given below: library(R2WinBUGS) set.seed(1) x1=rnorm(25) x2=rnorm(25) n=25 #i know that the systems are not related but this will be extended later. y1=2+5*x1+rnorm(25)*2 y2=25-7*x2+rnorm(25)*2 X1=cbind(1,x1) X2=cbind(1,x2) Y=cbind(y1,y2) I=diag(2) J=diag(2)*0.001 m=matrix(0,nrow=2,ncol=0) init<-list(b=matrix(0,nrow=2,ncol=2),tau=1) inits<-list(init,init,init) data<-c("n","Y","X1","X2","I","J","m") parameters<-c("b","tau") a<-bugs(data=data, inits=inits, parameters, model.file="c:/try/sur.txt", n.chains = 3, n.iter = 1000, bugs.directory = "c:/Program Files/WinBUGS14/", working.directory = "c:/try", clearWD = FALSE,codaPkg = FALSE,debug=T) model {     for (i in 1:n)     {         Y[i,1:2] ~ dmnorm(mu[i,],P[1:2,1:2])           # means in separate time series           mu[i,1] <- inprod(X1[i,],b[,1])           mu[i,2] <- inprod(X2[i,],b[,2])           P[1:2,1:2]<-tau*I[1:2,1:2]      }      # priors on regression coefficients      for (i in 1:2)     {          for (j in 1:2)          {              b[i,j]<-dnorm(0,0.001)           }     }     tau~dgamma(0.001,0.001) } thanking you in advance / allan ------------------------------------------------------------------- This list is for discussion of modelling issues and the BUGS software. For help with crashes and error messages, first mail [log in to unmask] To mail the BUGS list, mail to [log in to unmask] Before mailing, please check the archive at www.jiscmail.ac.uk/lists/bugs.html Please do not mail attachments to the list. To leave the BUGS list, send LEAVE BUGS to [log in to unmask] If this fails, mail [log in to unmask], NOT the whole list ```