User Tools

Site Tools


r-credplot

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

======Credible Interval Plot====== A type of forest plot for credible (and other) intervals =====Code===== <code c> # credplot - a type of forest plot # for credible (and other) intervals # m - estimates # mlo - lower bound # mhi - upper bound # cen - if(!is.na(cen)) abline(v=cen) credplot <- function (m, mlo, mhi, cen = NA, ...) { require(lattice) if(is.null(names(m))) names(m) <- as.character(1:length(m)) rge <- range(c(mlo, mhi)) rge[1] <- rge[1] - 0.05 * diff(rge) rge[2] <- rge[2] + 0.05 * diff(rge) dotplot(m, mlo = mlo, mhi = mhi, cen = cen, xlim = rge, ..., panel = function(x, y, mlo = mlo, mhi = mhi, cen = cen, horizontal, levels.fos, ...) { if (missing(levels.fos)) { if (horizontal) levels.fos <- unique(y) else levels.fos <- unique(x) } if (horizontal) panel.segments(x0 = mlo, y0 = levels.fos, x1 = mhi, y1 = levels.fos) else panel.segments(x0 = levels.fos, y0 = mlo, x1 = levels.fos, y1 = mhi) if (!is.na(cen)) { if (horizontal) panel.abline(v = cen, lty = 2) else panel.abline(h = cen, lty = 2) } panel.dotplot(x, y, horizontal, levels.fos = levels.fos, lty=0,...) }) } </code> =====Example===== The following code generates a plot similar to that below. <code c> m <- rnorm(10, 0, 1/10) mlo <- m - 1/10 mhi <- m + 1/10 credplot(m, mlo, mhi, cen=0) </code> {{:credplot.png|credplot.png}}

r-credplot.1363726546.txt.gz · Last modified: 2017/09/20 19:05 (external edit)