Dear UseRs, Apologies, I tried to post to the list yeasterday, but (for some reason) part of my message got missed off. Here's a second attempt. 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. Error in FUN(X[[1L]], ...) : .C(..): 'type' must be "real" for this format To give a little more context, my bugs() command (for a multilevel ordinal logit similar to Gelman and Hill, Data Analysis Using Regression and Multilevel/Hierarchical Models p. 383 is:> Wednesbury.data <- list ("n.judge", "n", "n.cut", "y", "judge", "ct",+ "ra", "lg")> Wednesbury.inits <- function(){+ list(C=matrix(0,39,2)) + }> Wednesbury.parameters <- c("C", "b1", "b2", "b3") > Wednesbury.sim <- 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)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)>Any help greatly appreciated. Lindsay Stirton School of Law, University of Manchester
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