[R] R and WinBUGS (via R2WinBUGS) error

Ben Bolker bolker at ufl.edu
Tue Jan 20 13:56:32 CET 2009


  What you have given us helps a little bit.

Lindsay Stirton <Lindsay.Stirton <at> manchester.ac.uk> writes:

> I am having some problems using R with WinBUGS using the R2WinBUGS
> package. Specifically, when I try to run bugs() I get the following
> message.

> 
[snip]
> Error in FUN(X[[1L]], ...) :
>    .C(..): 'type' must be "real" for this format
> 
> 
> > Wednesbury.data <- list ("n.judge", "n", "n.cut", "y", "judge", "ct",
> + "ra", "lg")

 [snip]

> Error in FUN(X[[1L]], ...) :
>    .C(..): 'type' must be "real" for this format
> >
> 
> This problem was discussed before  
> (https://stat.ethz.ch/pipermail/r-help/2008-August/171726.html), but  
> the discussion didn't seem to help me. As suggested on that post,  
> traceback() gives the following:
> 
> > traceback()
> 6: .C("str_signif", x = x, n = n, mode = as.character(mode), width =  
> as.integer(width),
>         digits = as.integer(digits), format = as.character(format),
>         flag = as.character(flag), result = blank.chars(i.strlen),
>         PACKAGE = "base")
> 5: FUN(X[[1L]], ...)
> 4: lapply(data.list, formatC, digits = digits, format = "E")
> 3: write.datafile(lapply(data.list, formatC, digits = digits, format = "E"),
>         file.path(dir, data.file))
> 2: bugs.data(data, dir = getwd(), digits)
> 1: bugs(data = "Wednesbury.data", inits = "Wednesbury.inits",  
> parameters = "Wednesbury.parameters",
>         model.file = "p:/Wednesbury09/Wednesbury.bug", n.chains = 1,
>         n.burnin = 1000, n.sims = 10000, bugs.directory = "c:/Program  
> Files/WinBUGS14/",
>         program = "WinBUGS", debug = TRUE)

   What this tells us is that the problem occurs while
R2WinBUGS is trying to write the data out to files on disk
whence WinBUGS will pick them up. One of your data items
("n.judge", "n", "n.cut", "y", "judge", "ct", "ra", "lg")
may be wonky.

  What happens if you try out formatC on the data items one
at a time, i.e.

formatC(n.judge,digits=5,format="E")
formatC(n,digits=5,format="E")
etc.?

  This would be easier if you had given us a reproducible
example -- i.e. either your actual data (if it is something
you can share), or preferably a small subset of your data
that demonstrate the problem. One often stumbles across the
answer to problem in the process of trying
to reduce the problem to a small subset ...

  Ben Bolker




More information about the R-help mailing list