shadeDist {fastGraph} | R Documentation |
Displays Area Under Curve of Probability Density Function
Description
This function plots a probability density function, shades the area under the curve, and computes the probability.
Usage
shadeDist(xshade = NULL, ddist = "dnorm", parm1 = NULL, parm2 = NULL, lower.tail = TRUE,
xlab=NULL, xmin = NULL, xmax = NULL, xtic = TRUE, digits.prob = 4,
digits.xtic = 3, is.discrete = NULL, additional.x.range = NULL, main = NULL,
col = c("black", "red"), lwd = 2, ...)
Arguments
xshade |
A single number or vector of two numbers, denoting values on the x-axis where shading under the curve begins and ends.
However, if |
ddist |
Character variable naming the probability density function to be graphed.
May be set to "dprop" for a sample proportion, using the same arguments as |
parm1 |
The first argument in |
parm2 |
The second argument in |
lower.tail |
Logical; if |
xlab |
The label of the |
xmin |
The minimum x-value to be graphed. |
xmax |
The maximum x-value to be graphed. |
xtic |
Logical or a vector of numbers.
If |
digits.prob |
The number of significant digits listed in the probability. |
digits.xtic |
The number of significant digits listed on the x-axis. |
is.discrete |
Logical; indicating whether or not the distribution is discrete.
If |
additional.x.range |
A vector of two additional x-values for evaluating the function.
This argument would be needed only if the user is dissatisfied with the domain determined by the function.
This argument is ignored if |
main |
The main title given for the graph. |
col |
A vector of size two, specifying the colors of the density curve and the shading, respectively. |
lwd |
The line width for discrete distributions. |
... |
Optional arguments to be passed to the |
Details
When illustrating a left-sided p-value or any other left-sided probability,
xshade
should be a single number and set lower.tail=TRUE
(default).
When illustrating a right-sided p-value or any other right-sided probability,
xshade
should be a single number and set lower.tail=FALSE
.
When illustrating a two-sided p-value or any other two-sided probability,
xshade
should be a vector of two numbers and set lower.tail=TRUE
(default).
When illustrating the complement of a two-sided p-value or the complement of any other two-sided probability,
xshade
should be a vector of two numbers and set lower.tail=FALSE
.
Note
The numeric value of the population median typically is shown on the x-axis when xshade
is not NULL
,
provided that this number actually fits on the x-axis; see description for argument xtic
above.\
This function shadeDist
calls functions getMinMax
,
plot
, and curve
.
Author(s)
Steven T. Garren, James Madison University, Harrisonburg, Virginia, USA
See Also
Examples
par( mfrow=c(3,3) )
shadeDist( qnorm(0.975), "dnorm", 0, 1 ) # P(Z<1.96) where Z ~ N(0,1)
shadeDist( qnorm(0.975), lower.tail=FALSE ) # P(Z>1.96) where Z ~ N(0,1)
# P(40<X<60) where X~N(mu=50,sigma=10)
shadeDist( c( 40, 60 ), , 50, 10, lower.tail=FALSE, col=c("black", "lightblue") )
shadeDist( c( 40, 60 ), "dnorm", 50, 10, col=c("purple", "lightgreen") )
shadeDist( 6.8, "dchisq", 4, lower.tail=FALSE ) # Chi-squared distribution with 4 d.f.
shadeDist( c( -1.3, 1.3 ), "dt", 13 ) # t with 13 d.f.
shadeDist( 1.19, "dt", 15, 3, lower.tail=FALSE ) # t with 15 d.f. and non-centrality parameter=3
shadeDist( 2.1, "df", 4, 25, lower.tail=FALSE, col=c("hotpink","turquoise") ) # F with 4 and 25 d.f.
shadeDist( 0.6, "dprop", 20, 0.7, xmin=0.4 ) # Probability for sample proportion with n=20 and p=0.7
par( mfrow=c(1,1) )