R/confint.mcmc.list.dc.R

Defines functions confint.mcmc.list.dc

Documented in confint.mcmc.list.dc

confint.mcmc.list.dc <-
function(object, parm, level = 0.95, ...)
{
    ## handling names and subsetting according to parm
    pnames <- varnames(object)
    if (missing(parm)) 
        parm <- pnames
    else if (is.numeric(parm)) 
        parm <- pnames[parm]
    if (is.null(parm))
        parm <- 1
    ## confidence levels based on level arg
    a <- (1 - level)/2
    a <- c(a, 1 - a)
    ## scientific formatting
    np <- length(parm)
    pct <- paste(format(100 * a, trim = TRUE, 
        scientific = FALSE, digits = 3), "%")
    ## empty array to fill up with values
    ci <- array(NA, dim = c(np, 2L), dimnames = list(parm, pct))
    ## retrieve posterior means
    cf <- coef(object)
    ## Normal quantiles
    fac <- qnorm(a)
    ## DC SD calculation
    ses <- dcsd(object)[parm]
    ## calculates actual CIs
    ci[] <- cf[parm] + ses %o% fac
    ci
}

Try the dclone package in your browser

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

dclone documentation built on July 10, 2023, 2:03 a.m.