Haoda Fu
2009-Jul-20 03:05 UTC
[R] HELP: BRUGS/WinBUGS/RBUGS Response is a combination of random variables
Hi, Is there anyone know if BUGS language allows the combination of variables as response such as Y[i] <- a*X1[i]+b*X2[i] Y[i] ~ dnorm(c,d) It seems doesn't work in my model. The problem is between two ######. The error message is> modelCheck("BayesBioMarker.BUGS")model is syntactically correct> modelData(paste("BUGS_data.txt",sep=""))data loaded> modelCompile(numChains=1)multiple definitions of node bm[1] ================================== model { for(iter in 1:numSubj){ bmd[iter] ~ dnorm(u[trt[iter]+1],sdbmd.precision); ############### bm[iter] <- inprod(biomarker[iter,1:4], bta[1:4]) bm[iter] ~ dnorm(bmu[iter], sdbm.precision); ############### bmu[iter] <- (1-delta[trt[iter]+1])*u[trt[iter]+1]+ delta[trt[iter]+1]*(u[1]+u[2])/2; } for(iter in 1:4){ bta[iter] ~ dnorm(0, 0.000001); } for (iter in 1:2){ delta[iter] ~ dbeta(0.0001,0.0001); u[iter] ~ dnorm(0,000001); } sdbmd.precision ~ dgamma(0.00001,0.00001); sdbm.precision ~ dgamma(0.00001,0.00001); } ==================Data list(biomarker= structure(.Data= c(-1.6332505600E-01, -9.9820335000E-02, 4.0692602900E-01, -8.2650000000E-03, -6.6739468400E-01, -1.9444291700E-01, -2.5035248500E-01, -1.5926000000E-02, 2.5951119500E-01, 3.1943077100E-01, 2.1915456300E-01, -7.0600000000E-04, -1.1407237740E+00, -4.7155522000E-01, -1.4495155440E+00, 1.7036000000E-02, -1.9105523700E-01, -5.6980210000E-03, -8.4883829700E-01, 4.9390000000E-03), .Dim=c(5, 4)), bmd=c(-4.9440000000E-03, 3.5207000000E-02, 2.5975000000E-02, 2.7394000000E-02, 7.5010000000E-03), trt=c(1.0000000000E+00, 0.0000000000E+00, 0.0000000000E+00, 1.0000000000E+00, 1.0000000000E+00), numSubj=5.0000000000E+00)
Uwe Ligges
2009-Jul-20 08:43 UTC
[R] HELP: BRUGS/WinBUGS/RBUGS Response is a combination of random variables
I think this is a question for some BUGS related mailing list rather than the R mailing lists. Best, Uwe Ligges Haoda Fu wrote:> Hi, > > Is there anyone know if BUGS language allows the combination of variables as response > > such as > Y[i] <- a*X1[i]+b*X2[i] > Y[i] ~ dnorm(c,d) > > > It seems doesn't work in my model. The problem is between two ######. > The error message is >> modelCheck("BayesBioMarker.BUGS") > model is syntactically correct >> modelData(paste("BUGS_data.txt",sep="")) > data loaded >> modelCompile(numChains=1) > multiple definitions of node bm[1] > > > ==================================> model > { > for(iter in 1:numSubj){ > bmd[iter] ~ dnorm(u[trt[iter]+1],sdbmd.precision); > ############### > bm[iter] <- inprod(biomarker[iter,1:4], bta[1:4]) > bm[iter] ~ dnorm(bmu[iter], sdbm.precision); > ############### > bmu[iter] <- (1-delta[trt[iter]+1])*u[trt[iter]+1]+ delta[trt[iter]+1]*(u[1]+u[2])/2; > } > for(iter in 1:4){ > bta[iter] ~ dnorm(0, 0.000001); > } > for (iter in 1:2){ > delta[iter] ~ dbeta(0.0001,0.0001); > u[iter] ~ dnorm(0,000001); > } > sdbmd.precision ~ dgamma(0.00001,0.00001); > sdbm.precision ~ dgamma(0.00001,0.00001); > } > ==================> Data > > > list(biomarker= structure(.Data= c(-1.6332505600E-01, -9.9820335000E-02, 4.0692602900E-01, -8.2650000000E-03, -6.6739468400E-01, -1.9444291700E-01, -2.5035248500E-01, -1.5926000000E-02, 2.5951119500E-01, 3.1943077100E-01, 2.1915456300E-01, -7.0600000000E-04, -1.1407237740E+00, -4.7155522000E-01, -1.4495155440E+00, 1.7036000000E-02, -1.9105523700E-01, -5.6980210000E-03, -8.4883829700E-01, 4.9390000000E-03), .Dim=c(5, 4)), bmd=c(-4.9440000000E-03, 3.5207000000E-02, 2.5975000000E-02, 2.7394000000E-02, 7.5010000000E-03), trt=c(1.0000000000E+00, 0.0000000000E+00, 0.0000000000E+00, 1.0000000000E+00, 1.0000000000E+00), numSubj=5.0000000000E+00) > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Richard.Cotton at hsl.gov.uk
2009-Jul-20 09:23 UTC
[R] HELP: BRUGS/WinBUGS/RBUGS Response is a combination of random variables
> Is there anyone know if BUGS language allows the combination of > variables as response> It seems doesn't work in my model. The problem is between two ######.> > modelCompile(numChains=1) > multiple definitions of node bm[1]> ############### > bm[iter] <- inprod(biomarker[iter,1:4], bta[1:4]) > bm[iter] ~ dnorm(bmu[iter], sdbm.precision); > ###############The problem seems to be that you've defined bm[iter] as a logical node (<-), then redefined it as a stochastic node (~). If you need more help, try the BUGS mailing list. (See http://www.mrc-bsu.cam.ac.uk/bugs/overview/list.shtml) Regards, Richie. Mathematical Sciences Unit HSL ------------------------------------------------------------------------ ATTENTION: This message contains privileged and confidential inform...{{dropped:22}}