cdist: Central portion of a distribution

Description Usage Arguments Value Note Examples

View source: R/cdist.R

Description

This function determines the critical values for isolating a central portion of a distribution with a specified probability. This is designed to work especially well for symmetric distributions, but it can be used with any distribution.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
cdist(dist = "norm", p, plot = TRUE, verbose = FALSE,
  invisible = FALSE, digits = 3L, xlim, ylim, resolution = 500L,
  return = c("values", "plot"), pattern = c("rings", "stripes"), ...,
  refinements = list())

xcgamma(...)

xct(...)

xcchisq(...)

xcf(...)

xcbinom(...)

xcpois(...)

xcgeom(...)

xcnbinom(...)

xcbeta(...)

Arguments

dist

a character string naming a distribution family (e.g., "norm"). This will work for any family for which the usual d/p/q functions exist.

p

the proportion to be in the central region, with equal proportions in either "tail".

plot

a logical indicating whether a plot should be created

verbose

a logical indicating whether a more verbose output value should be returned.

invisible

a logical

digits

the number of digits desired

xlim

x limits. By default, these are chosen to show the central 99.8% of the distribution.

ylim

y limits

resolution

number of points used for detecting discreteness and generating plots. The default value of 5000 should work well except for discrete distributions that have many distinct values, especially if these values are not evenly spaced.

return

If "plot", return a plot. If "values", return a vector of numerical values.

pattern

One of "stripes" or "rings". In the latter case, pairs of regions (from the outside to the inside) are grouped together for coloring and probability calculation.

...

additional arguments passed to the distribution functions. Typically these specify the parameters of the particular distribution desired. See the examples.

refinements

A list of refinements to the plot. See ggformula::gf_refine().

Value

a pair of numbers indicating the upper and lower bounds, unless verbose is TRUE, in which case a 1-row data frame is returned containing these bounds, the central probability, the tail probabilities, and the name of the distribution.

Note

This function is still experimental and changes the input or output formats are possible in future versions of the package.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
cdist( "norm", .95)
cdist( "t", c(.90, .95, .99), df=5)
cdist( "t", c(.90, .95, .99), df=50)
cdist( "t", .95, df=c(3,5,10,20))
cdist( "t", .95, df=c(3,5,10,20), verbose = TRUE )
cdist( "norm", .95, mean=500, sd=100 )
cdist( "chisq", c(.90, .95), df=3 )
# CI
x <- rnorm(23, mean = 10, sd = 2)
cdist("t", p = 0.95, df=22)
mean(x) + cdist("t", p = 0.95, df=22) * sd(x) / sqrt(23)
confint(t.test(x))
cdist("t", p = 0.95, df=22, verbose = TRUE)

ProjectMOSAIC/mosaic documentation built on Aug. 19, 2018, 9:14 a.m.