Type: | Package |
Title: | Functions to Plot Confidence Interval |
Version: | 1.0 |
Date: | 2017-08-14 |
Author: | Toshiaki Ara |
Maintainer: | Toshiaki Ara <toshiaki.ara@gmail.com> |
Description: | Plot confidence interval from the objects of statistical tests such as t.test(), var.test(), cor.test(), prop.test() and fisher.test() ('htest' class), Tukey test [TukeyHSD()], Dunnett test [glht() in 'multcomp' package], logistic regression [glm()], and Tukey or Games-Howell test [posthocTGH() in 'userfriendlyscience' package]. Users are able to set the styles of lines and points. This package contains the function to calculate odds ratios and their confidence intervals from the result of logistic regression. |
Imports: | MASS, multcomp |
Suggests: | BSDA, fmsb, userfriendlyscience |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
URL: | https://github.com/toshi-ara/CIplot |
BugReports: | https://github.com/toshi-ara/CIplot/issues/ |
RoxygenNote: | 6.0.1 |
Collate: | 'CIplot.R' 'CIplot.default.R' 'CIplot.htest.R' 'CIplot.TukeyHSD.R' 'CIplot.glht.R' 'CIplot.glm.R' 'CIplot.ORci.R' 'CIplot.posthocTGH.R' 'ORci.R' 'print.ORci.R' |
NeedsCompilation: | no |
Packaged: | 2017-08-13 22:41:24 UTC; ara |
Repository: | CRAN |
Date/Publication: | 2017-08-14 08:37:08 UTC |
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)
}
Calculate odds ratios and their confidence intervals
from glm
object
Description
Calculate odds ratios and their confidence intervals
from glm
object
Usage
ORci(x, conf.level = 0.95)
Arguments
x |
|
conf.level |
the confidence interval. Default is 0.95. |
Value
an object ORci
and matirix
classes with four columns.
- OR
odds ratio
- lwr
lower conficence intarval
- upr
upper conficence intarval
- p.value
P value by logistic regression
Examples
require(graphics)
require(MASS)
data(birthwt)
x <- glm(low ~ age + lwt + smoke + ptl + ht + ui, data = birthwt,
family = binomial)
OR1 <- ORci(x)
CIplot(OR1, las = 1)
Print Methods for Odds Ratios and their Confidence Intervals
of ORci
object
Description
Print odds ratios and their confidence intervals of ORci
object.
Usage
## S3 method for class 'ORci'
print(x, ...)
Arguments
x |
|
... |
other options for print such as |
See Also
glm
, ORci
.
Examples
require(MASS)
data(birthwt)
x <- glm(low ~ age + lwt + smoke + ptl + ht + ui, data = birthwt,
family = binomial)
OR1 <- ORci(x)
print(OR1, digits = 3)