File: jags.R

package info (click to toggle)
r-cran-coda 0.13-2-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 456 kB
  • sloc: makefile: 2
file content (29 lines) | stat: -rw-r--r-- 902 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"read.jags" <- function (file = "jags.out", start, end, thin, quiet=FALSE) 
{
  if (!is.R()) {
    stop("This function is not yet available in S-PLUS")
  }
  read.coda(file, start, end, thin, quiet)
}

bugs2jags <- function(infile, outfile)
{
  if (!is.R()) {
    stop("This function is not yet available in S-PLUS")
  }
  
  ## Convert S-style data for WinBUGS into the R dump format
  ## used by JAGS.
  bugs.dat <- dget(infile)
  for (bugs.variable.name in names(bugs.dat)) {
    if(!is.null(dim(bugs.dat[[bugs.variable.name]]))) {
      ## Manually reverse order of dimensions of arrays
      dim(bugs.dat[[bugs.variable.name]]) <-
        rev(dim(bugs.dat[[bugs.variable.name]]))
      ## Then transpose
      bugs.dat[[bugs.variable.name]] <- aperm(bugs.dat[[bugs.variable.name]])
    }
    assign(bugs.variable.name, bugs.dat[[bugs.variable.name]])
  }
    dump(names(bugs.dat), file=outfile)
}