R/bugs.inits.R

"bugs.inits" <- 
function (inits, n.chains, digits,
          inits.files = paste("inits", 1:n.chains, ".txt", sep = "")){
    if(!is.null(inits)) {
        for(i in 1:n.chains) {
            if(is.function(inits))
                if(is.R()) {
                    write.datafile(lapply(inits(), formatC, digits = digits, format = "E"),
                        inits.files[i])
                } else {
                    writeDatafileS4(inits(), towhere = inits.files[i])
                }
            else if(is.R()) {
                write.datafile(lapply(inits[[i]], formatC, digits = digits, format = "E"), 
                    inits.files[i])
                } else {
                    writeDatafileS4(inits[[i]], towhere = inits.files[i])
                }
        }
    }
    return(inits.files)
}

Try the R2WinBUGS package in your browser

Any scripts or data that you put into this service are public.

R2WinBUGS documentation built on June 24, 2024, 5:18 p.m.