CIplot {CIplot} | R Documentation |
Plot Confidential Interval
Description
A function to plot confidential interval for
such as htest
, TukeyHSD
,
glht
(multcomp),
glm
(logistic regression only!)
and posthocTGH
(userfriendlyscience) objects.
Usage
CIplot(x, ...)
## Default S3 method:
CIplot(x, xlog = FALSE, xlim = NULL, xlab = NULL,
yname = TRUE, las = 0, pch = 21, pcol = 1, pcolbg = "white",
pcex = 1, conf.level = 0.95, cilty = 1, cilwd = 1, cicol = 1, v,
vlty = 2, vlwd = 1, vcol = 1, main = NULL, ...)
## S3 method for class 'htest'
CIplot(x, xlog = FALSE, xlim = NULL, xlab = NULL,
yname = FALSE, v = NULL, ...)
## S3 method for class 'TukeyHSD'
CIplot(x, xlab = "Differences in mean", v = 0, ...)
## S3 method for class 'glht'
CIplot(x, xlab = "Differences in mean", v = 0, ...)
## S3 method for class 'glm'
CIplot(x, conf.level = 0.95, xlog = TRUE,
xlab = "Odds Ratio", v = 1, ...)
## S3 method for class 'ORci'
CIplot(x, xlog = TRUE, xlab = "Odds Ratio", v = 1, ...)
## S3 method for class 'posthocTGH'
CIplot(x, xlab = "Differences in mean", v = 0, ...)
Arguments
x |
|
... |
other options for x-axis. |
xlog |
(logical) if |
xlim |
the x limits (x1, x2) of the plot. |
xlab |
a title for the plot. |
yname |
If |
las |
numeric in 0,1,2,3; the style of axis labels.
Default is 0. see also |
pch |
plotting 'character', i.e., symbol to use. |
pcol |
color code or name of the points. |
pcolbg |
background (fill) color for the open plot symbols given by 'pch = 21:25'. |
pcex |
character (or symbol) expansion of points. |
conf.level |
|
cilty |
line types of conficence intervals. |
cilwd |
line width of conficence intervals. |
cicol |
color code or name of conficence intervals. |
v |
the x-value(s) for vertical line. |
vlty |
line types of vertical line. |
vlwd |
line width of vertical line. |
vcol |
color code or name of vertical line. |
main |
a main title for the plot. |
Note
CIplot
was made based on plot.TukeyHSD
.
# File src/library/stats/R/TukeyHSD.R # Part of the R package, https://www.R-project.org # # Copyright (C) 2000-2001 Douglas M. Bates # Copyright (C) 2002-2015 The R Core Team
See Also
plot
, axis
, points
, par
.
Examples
##### default (matrix or data.frame)
require(graphics)
x <- matrix(c(3, 1, 5,
4, 2, 6), 2, 3, byrow = TRUE)
colnames(x) <- c("esti", "lwr", "upr")
rownames(x) <- c("A", "B")
CIplot(x, xlab = "difference", v = 2, las = 1)
##### 'htest' objects
require(graphics)
## t test
set.seed(1234)
a <- rnorm(10, 10, 2); b <- rnorm(10, 8, 2)
x <- t.test(a, b)
CIplot(x)
## binomial test
x <- binom.test(5, 20)
CIplot(x, xlim = c(0, 1))
## Fisher's exact test
x <- matrix(c(10, 7, 8, 9), 2, 2, byrow = TRUE)
res <- fisher.test(x)
CIplot(res, xlog = TRUE)
##### 'TukeyHSD' objects
require(graphics)
## Tukey test
aov1 <- aov(breaks ~ tension + wool, data = warpbreaks)
x <- TukeyHSD(aov1)
oldpar <- par(no.readonly = TRUE)
par(mfrow = c(1, 2))
CIplot(x, las = 1)
par(oldpar)
## example of line type and color
aov1 <- aov(breaks ~ tension, data = warpbreaks)
x <- TukeyHSD(aov1)
CIplot(x, las = 1,
pcol = 2:4, pcolbg = 2:4, cicol = 2:4,
vlty = 1, vcol = "gray")
##### 'glht' objects
require(graphics)
## Tukey test
require(multcomp)
aov1 <- aov(breaks ~ tension, data = warpbreaks)
x <- glht(aov1, linfct = mcp(tension = "Tukey"))
CIplot(x, las = 1)
## Dunnett test
x <- glht(aov1, linfct = mcp(tension = "Dunnett"))
CIplot(x, las = 1)
##### 'glm' object: logistic regression only!
## odds ratio
require(graphics)
require(MASS)
data(birthwt)
x <- glm(low ~ age + lwt + smoke + ptl + ht + ui, data = birthwt,
family = binomial)
CIplot(x, las = 1)
##### 'posthocTGH' object
## Tukey or Games-Howell methos
require(graphics)
if (require(userfriendlyscience)) {
x <- posthocTGH(warpbreaks$breaks, warpbreaks$tension)
CIplot(x, las = 1)
}