Hadassa Brunschwig wrote:
> Hi R-Help!
>
> I am trying to use R2WinBUGS but I get the following error message in
WinBUGS
> (and there must be something wrong with my R statement as I tried it
directly in
> WinBUGS and it worked):
>
> display(log)
> check(C:/Documents and Settings/Daikon/Roche/pop_model.txt)
> model is syntactically correct
> data(C:/Documents and Settings/Daikon/Roche/data.txt)
> expected key word structure
> compile(7)
> ...(and of course nothing works after that)
>
> and when I close WinBUGS i get:
> Error in file(file, "r") : unable to open connection
> In addition: Warning message:
> cannot open file 'codaIndex.txt'
>
> Does anyone know what this 'expected key word structure' means?
> This is my R code (and I guess my model file is ok):
>
> modelA <- c("C:/Documents and
Settings/Daikon/Roche/pop_model.txt")
> n <- length(unique(subsetA$subject)) #number of subjects
> nt <- 13 #number of days
> Y <- subsetA$concentr #concentration per
day/subject
> t <- 1:13 #days
> dataA <-
list("n","nt","Y","t")
> parameters <-
c("tau","C0","st90","C0.pop","st90.pop","tau.cpop","tau.stpop")
> inits <-
>
list(tau=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),C0=5,st90=4,C0.pop=5,st90.pop=4,tau.cpop=0.2,tau.stpop=1)
> mcmcA <-
>
bugs(dataA,inits,parameters,modelA,debug=T,n.chains=7,bugs.directory="c:/Program
> Files/WinBUGS14",working.directory="C:/Documents and
Settings/Daikon/Roche")
Which versions of R, WinBUGS and R2WinBUGS?
Your example is not reproducible for us.
I'd take a look whether dimensions are OK and whether subsetA$concentr
is in appropriate object, but without data and model file I am unable to
help for the data part.
For the inits part, please see ?bugs:
inits: a list with n.chains elements; each element of the list is itself
a list of starting values for the WinBUGS model, or a function creating
(possibly random) initial values. Alternatively, if inits = NULL,
initial values are generated by WinBUGS
Looks like you want to have the same inits for each chain. In order not
to repeat the inits 7 times, you might want to specify them simply as a
function such as:
inits <- function(){
list(tau = rep(1, 17), C0 = 5, st90 = 4, C0.pop = 5, st90.pop = 4,
tau.cpop = 0.2, tau.stpop = 1)
}
Uwe Ligges
[Further correspondence on this particular topic, please respond to to
the package maintainer (Sibylle) and me directly rather than to R-help.]
>
> Thanks so much...
>
> Hadassa
>
>