Skip to content

WinBUGS with R

5 messages · Lindsay Stirton, Richard Cotton, Uwe Ligges +1 more

#
Dear UseRs,

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")
#
Debugging your BUGS model or dataset via R is a bit of a pain.  I find 
that the best way (or maybe least worst way) to weed out the problems when 
you get an error like this is to find the files (model/data/inits) that 
R2WinBUGS has created and open them in WinBUGS itself.  Run the Model 
Specification tool and you can more easily determine which part of the 
file the problem lies in.

Just looking at your Wednesbury.inits variable, you don't need to define 
it as a function
Wednesbury.inits <- list(list(C=matrix(0,39,2)))
will do.

Also, I'm not sure if WinBUGS understands matrix data types (though I may 
be wrong).

Regards,
Richie.

Mathematical Sciences Unit
HSL


------------------------------------------------------------------------
ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}
#
Richard.Cotton at hsl.gov.uk wrote:
Untested, but I think it needs to be

  Wednesbury.inits <- function(){
        matrix(0,39,2)
  }

and a function is of interest if some randomness should be in the inits...
Yes.
It does.


Uwe
#
Uwe Ligges wrote:
No, in fact I was wrong...

Uwe
#
We are having good success using JAGS and the rjags package.  We've put 
some information at http://biostat.mc.vanderbilt.edu/JAGSInstallExample 
for linux.  It's nice to have a native linux executable, thanks to 
Martyn Plummer.   For those unfamiliar with JAGS, it uses the BUGS 
language, i.e., the user still creates a .bugs file as with WinBUGS.

Frank
Uwe Ligges wrote: