[R] Problem using BRugs

Uwe Ligges ligges at statistik.tu-dortmund.de
Sun Oct 17 17:46:08 CEST 2010



On 15.10.2010 20:40, Sally Luo wrote:
> Hi R users,
>
> I am trying to call openbugs from R.  And I got the following error message:
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> model is syntactically correct
> expected the collection operator c error pos 8 (error on line 1)

Well, something is wrong, but hard to say without the data.
I'd suggest to try the whole thing in OpenBUGS at first and see if it 
runs there. Afterwards go into R where it should work as well.
If you still fail to find the error, you may send the stuff to my 
address privately and I may find some time to take a look. But please 
try yourself at first.

Best wishes,
Uwe Ligges







> variable ww is not defined in model or in data set
> [1] "C:\\DOCUME~1\\maomao\\LOCALS~1\\Temp\\RtmpqJk9R3/inits1.txt"
> Initializing chain 1: model must be compiled before initial values loaded
> model must be initialized before updating
> model must be initialized before DIC an be monitored
> Error in samplesSet(parametersToSave) :
>    model must be initialized before monitors used
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> I did define variable "ww" in my data and model (they are listed below).  I
> am not sure if this is due to some errors in my code (please see below) or
> because openbugs cannot handle the model I am using.  In my model, y[i] also
> depends on all other y[j]s.  Could you help me figure out the problem and
> hopefully get the code to work?
>
> Many thanks for your help.   --- Maomao
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> data<-list("y","cap2","pol2","cap1","pol1","g","wo","wd","ww","mu","tau")
>
> inits<-function() {list(beta=beta0, rho_o=rho_o_0, rho_d=rho_d_0,
> rho_w=rho_w_0)}
>
> parameters<-c("beta", "rho_o", "rho_d", "rho_w")
>
> probit.sim<-BRugsFit(data,inits,parameters,modelFile="spatial.openbugs.txt",numChains=1,nIter=2000)
>
>
>
> # my model
>
> model {
>
> for (i in 1:676) {
>
> y[i] ~ dbern(p[i])
>
> wwy[i]<- inprod(ww[i, 1:676] , y[])
>
> woy[i]<- inprod(wo[i, 1:676] , y[])
>
> wdy[i]<- inprod(wd[i, 1:676] , y[])
>
> probit(p[i])<- rho_o * woy[i] + rho_d * wdy[i] + rho_w * wwy[i] + beta[1] +
> beta[2] * cap2[i] + beta[3] * pol2[i] + beta[4] * cap1[i] + beta[5] *
> pol1[i] + beta[6] * g[i]+ e[i]
>
>                          }
>
> # Priors
>
> for (j in 1:6) {
>
> beta[1:6] ~ dmnorm(mu[1:6], tau[1:6, 1:6])
>
>                     }
>
> rho_o ~ dunif(-1,1)
>
> rho_d ~ dunif(-1,1)
>
> rho_w ~ dunif(-1,1)
>
> for (i in 1:676) {
>
> e[i] ~ dnorm(0, 1)
>
>                          }
>
>                  }
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



More information about the R-help mailing list