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.
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", ...)
inversionTestpq
returns a list with components:
Numeric. The result of applying the distribution function
(p
function) then the quantile function (q
function) to
the randomly generated set of \(x\) values.
Numeric. The set of \(x\) values generated by the r
function.
Numeric. The differences qpx
minus x
.
Numeric. Number of values sampled from the distribution.
inversionTestqp
returns a list with components:
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.
Numeric. The differences pqqs
minus qs
.
Character. The root name of the distribution to be tested.
Numeric. Set of quantiles to which quantile function then distribution function will be applied. See Details.
Numeric. Number of values to be sampled from the distribution. See Details.
Numeric. Values at which the distribution function is to be
evaluated. If NULL
values are drawn at random from the
distribution.
Value of rel.tol
and hence abs.tol
in calls
to integrate
. See integrate
.
Value of tol
in calls to uniroot
. See
uniroot
.
Character. If "spline"
quantiles are found from a
spline approximation to the distribution function. If
"integrate"
, the distribution function used is always obtained
by integration.
Additional arguments to allow specification of the parameters of the distribution.
David Scott d.scott@auckland.ac.nz, Christine Yang Dong c.dong@auckland.ac.nz
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.
## 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)
Run the code above in your browser using DataLab