inversionTests {DistributionUtils} | R Documentation |
Inversion Tests for Distributions
Description
Functions to check performance of distribution and quantile functions. Applying the distribution function followed by the quantile function to a set of numbers should reproduce the original set of numbers. Likewise applying the quantile function followed by the distribution function to numbers in the range (0,1) should produce the original numbers.
Usage
inversionTestpq(densFn = "norm", n = 10,
intTol = .Machine$double.eps^0.25,
uniTol = intTol, x = NULL, method = "spline", ...)
inversionTestqp(densFn = "norm",
qs = c(0.001, 0.01, 0.025, 0.05, 0.1, 0.2, 0.4, 0.5,
0.6, 0.8, 0.9, 0.95, 0.975, 0.99, 0.999),
uniTol = .Machine$double.eps^0.25,
intTol = uniTol, method = "spline", ...)
Arguments
densFn |
Character. The root name of the distribution to be tested. |
qs |
Numeric. Set of quantiles to which quantile function then distribution function will be applied. See Details. |
n |
Numeric. Number of values to be sampled from the distribution. See Details. |
x |
Numeric. Values at which the distribution function is to be
evaluated. If |
intTol |
Value of |
uniTol |
Value of |
method |
Character. If |
... |
Additional arguments to allow specification of the parameters of the distribution. |
Details
inversionTestpq
takes a sample from the specified distribution
of size n
then applies the distribution function, followed by
the quantile function.
inversionTestqp
applies the quantile function, followed by
the distribution function to the set of quantiles specified by
qs
.
In both cases the starting and ending values should be the same.
These tests are used in base R to check the standard distribution
functions. The code may be found in the file d-p-q-r.tests.R
in
the tests
directory.
Value
inversionTestpq
returns a list with components:
qpx |
Numeric. The result of applying the distribution function
(‘p’ function) then the quantile function (‘q’ function) to
the randomly generated set of |
x |
Numeric. The set of |
diffs |
Numeric. The differences |
n |
Numeric. Number of values sampled from the distribution. |
inversionTestqp
returns a list with components:
pqqs |
Numeric. The result of applying the quantile function
(‘q’ function) then the distribution function (‘p’ function) to
the quantiles |
qs |
Numeric. The set of quantiles. |
diffs |
Numeric. The differences |
Author(s)
David Scott d.scott@auckland.ac.nz, Christine Yang Dong c.dong@auckland.ac.nz
Examples
## Default distribution is normal
inversionTestpq()
inversionTestqp()
## Supply parameters
inversionTestpq(mean = 1, sd = 2)
inversionTestqp(mean = 1, sd = 2)
## Gamma distribution, must specify shape
inversionTestpq("gamma", shape = 1)
inversionTestqp("gamma", shape = 1)