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 NULL, no shading occurs.

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 dbinom.

parm1

The first argument in ddist, excluding the dummy argument. For example, if ddist="dnorm", then parm1 is the mean from "dnorm". Alternatively, parm1 may be set to be a vector of arguments, excluding the dummy argument. However, if ddist="dprop", then parm1 should be set to the size in dbinom.

parm2

The second argument in ddist, excluding the dummy argument. For example, if ddist="dnorm", then parm2 is the sd from "dnorm". Alternatively, parm2 may be set to be a vector of arguments, excluding both the dummy argument and parm1. However, if ddist="dprop", then parm2 should be set to the prob in dbinom.

lower.tail

Logical; if TRUE (default), the lowest region is shaded; otherwise, the next lowest region is shaded.

xlab

The label of the x variable.

xmin

The minimum x-value to be graphed.

xmax

The maximum x-value to be graphed.

xtic

Logical or a vector of numbers. If xtic is TRUE (default), then the numbers on the x-axis include the median and xshade. If xtic is TRUE, then the default numbers from plot are listed on the x-axis. If xtic is a vector of numbers, then these numbers are listed on the x-axis.

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 is.discrete is NULL, then shadeDist automatically makes the correct choice for density functions already named in the stats package.

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 ddist="dprop".

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 plot function (see par).

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

plotDist and shadePhat

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) )

[Package fastGraph version 2.1 Index]