denstrip.normal {denstrip} | R Documentation |
Draws a density strip for a normal or log-normal distribution with the given mean and standard deviation, based on computing the density at a large set of equally-spaced quantiles.
denstrip.normal(mean, sd, log=FALSE, nx=1000, ...) panel.denstrip.normal(...)
mean |
Mean of the normal distribution. |
sd |
Standard deviation of the normal distribution. |
log |
If TRUE then the strip for a log-normal distribution,
with mean and SD on the log scale mean and sd ,
respectively, is plotted. This may be useful for illustrating hazard ratios
or odds ratios.
|
nx |
Number of points to evaluate the density at. |
... |
Further arguments passed to denstrip ,
for example, at to position the strip on the y-axis,
or lattice=TRUE to use as a lattice panel function. panel.denstrip.normal(x,...) is equivalent to
denstrip.normal(x, lattice=TRUE,...) . |
Christopher Jackson <chris.jackson@mrc-bsu.cam.ac.uk>
x <- seq(-4, 4, length=10000) dens <- dnorm(x) plot(x, xlim=c(-5, 5), ylim=c(-1, 2), xlab="x", ylab="", type="n", axes=FALSE) axis(1) denstrip(x, dens, at=0, width=0.3) denstrip.normal(0, 1, at=1, width=0.3) ### log-normal distribution sdlog <- 0.5 x <- rlnorm(10000, 0, sdlog) plot(x, xlim=c(0, 5), ylim=c(-2, 4), xlab="x", , ylab="", type="n", axes=FALSE) axis(1) abline(v=1, lty=2, col="lightgray") denstrip(x, at=0, ticks=exp(-sdlog^2), width=0.4) # tick at theoretical maximum density denstrip(x, at=1, bw=0.1, ticks=exp(-sdlog^2), width=0.4) denstrip.normal(0, sdlog, log=TRUE, at=3, nx=1000, ticks=exp(-sdlog^2), width=0.4)