internals_for_distr {distr}R Documentation

Internal functions of package distr

Description

These functions are used internally by package distr.

Usage

.is.vector.lattice(x)
.is.consistent(lattice, support, eq.space = TRUE)
.make.lattice.es.vector(x)
.inArgs(arg, fct)
.isEqual(p0, p1, tol = min( getdistrOption("TruncQuantile")/2,
                                          .Machine$double.eps^.7))
.isEqual01(x)
.isIn(p0, pmat, tol = min( getdistrOption("TruncQuantile")/2,
                                          .Machine$double.eps^.7
                                          ))
.setEqual(x, y, tol = 1e-7)
.presubs(inp, frompat, topat)
.makeD(object, argList,  stand = NULL)
.makeP(object, argList,  sign = TRUE, correct = NULL)
.makeQ(object, lastCall, sign = TRUE, Cont = TRUE)
.plusm(e1, e2, Dclass = "DiscreteDistribution")
.multm(e1, e2, Dclass = "DiscreteDistribution")
.notwithLArg(D)
.getObjName(i = 1)
.discretizeP(D, lower, upper, h)   
.fm(x,f)
.fM(x,f)
.fM2(x,f)
.makeDd(x,y, yleft, yright)
.makePd(x,y, yleft, yright)
.makeQd(x,y, yleft, yright)
.makeQc(x,y, yleft, yright)
.makeDNew(x, dx, h = NULL, Cont = TRUE, standM = "sum")
.makePNew(x, dx, h = NULL, notwithLLarg = FALSE,
                      Cont = TRUE, myPf = NULL, pxl = NULL, pxu = NULL)
.makeQNew(x, px.l, px.u, notwithLLarg = FALSE, yL , yR, Cont = TRUE)

Arguments

x a (numeric) vector
y a (numeric) vector
f a function in one (numeric) argument
lattice a lattice (of class Lattice)
support a support vector
eq.space logical: shall we check for the support to be equally spaced?
arg a formal argument as character
fct a function
p0,p1 (numeric) vectors
pmat (matrix) a matrix with two columns where row-wise the left column is smaller than the right one
tol an error tolerance (numeric)
e1 a distribution object
e2 a numeric
object a distribution object
argList an (unevaluated) list of arguments passed to m(object) where m is in d,p,q
stand factor for a (Lebesgue) density to integrate to 1
sign the sign of the second operand — for multiplication at the moment
correct unevaluated R-code to correct for right-continuity (for multiplication with negative numerics at the moment)
lastCall unevaluated R-Code —gives how the result of a call to q(e1) is further transformed
Cont logical: TRUE if object is continuous
DClass character: name of distribution class
D a distribution object
i an integer
yleft, yright extrapolation value beyond left/right endpoint of grid
h numeric: grid width
standM standardization method — summation or integration
notwithLLarg logical — can we use log.p, lower.tail arguments for p,q-methods of first operand?
dx numeric: vector of cell-probabilities for the (discretized) distribution
myPf function with args x,y, yleft, yright (as approxfun): if given: replaces approxfun as interpolation method for continuos distributions
pxl,pxu numeric: if given vector of (lower/upper) cumulative probabilities
yL, yR argmin / argmax of p()-method
inp either a language object or a character vector
frompat vector of character strings containing regular expressions (or character string for fixed = TRUE) to be matched in the given character vector. Coerced by as.character to a character string if possible; (as argument pattern in gsub — but possibly of length >1).
topat a (vector of) replacement(s) for matched pattern in .presubs. Coerced to character if possible. For fixed = FALSE this can include backreferences "\1"' to "\9" to parenthesized subexpressions of pattern. For perl = TRUE only, it can also contain "\U" or "\L" to convert the rest of the replacement to upper or lower case; (as argument replacement in gsub— but possibly of length >1).

Details

.is.vector.lattice checks whether a given vector x is equally spaced. .is.consistent checks whether a given support vector support is consistent to a given lattice lattice — with or without checking if support is equally spaced. .make.lattice.es.vector makes an object of class Lattice out of a given (equally spaced) vector x.

.inArgs checks whether an argument arg is a formal argument of fct — not vectorized.

.isEqual checks whether p0 and p1 are equal to given tolerance. .isIn checks whether p0 lies in any of the intervals given by matrix pmat to given tolerance. .isEqual01(x) checks whether x is 0 or 1 to given tolerance. .setEqual sets all elements of x which are equal to some element of y up to tolerance tol, to exactly the respective element of y.

.notwithLArg checks whether object D was generated by simulations or if its slots p,q do not have lower.tail arguments.

.getObjName returns the name of the object in the ith operand. .discretizeP discretizes D to a grid of probabilities from lower to upper with width h.

.fm, .fM return the smallest / biggest value in (0,1) such that f(x) is finite; .fM2 is a variant of .fM using a lower.tail = FALSE argument.

.makeD, .makeP, .makeQ generate slots p,d,q for binary operations e1 /op/ e2 for a distribution object e1 and a numeric e2 —for the moment only /op/'s +,-,*,/ are implemented.

.plusm, .multm more specifically use .makeD, .makeP, .makeQ to generate slots p,d,q for +, *, respectively.

.makeDd, .makePd, .makeQd provide discrete analogues to approxfun for interpolation at non grid-values

.makeQc is an analogue to makeQd for absolutely continuous distributions using approxfun.

.makeDNew generates slot d for a new distribution object. In case of a discrete distribution it produces a step function with stepfun (using .makeDd) and standardizes to 1 by summation. In case of a continuous distribution it produces a density function with approxfun and standardizes to 1 by integration if the latter fails, it uses a trapezoid rule / summation for this purpose.

.makePNew generates slot p for a new distribution object. In case of a discrete distribution it produces a step function from cumsum applied to dx —or from pxl if this is given, with stepfun (using .makePd). In case of a continuous distribution it produces a cdf with approxfun. In case of RtoDPQ, approxfun is replaced by myPf which calls ecdf directly.

.makeQNew generates slot q for a new distribution object. In case of a discrete distribution it produces a step function (using .makeQd). Special care is taken for left continuity... In case of a continuous distribution it produces a quantile function with approxfun.

Value

.is.vector.lattice logical (length 1)
.is.consistent logical (length 1)
.notwithLArg logical (length 1)
.make.lattice.es.vector an object of class Lattice
.inArgs logical (length 1)
.isIn, .isEqual,.isEqual01 vector of logical
.fm,.fM, .fM2 a numeric of length 1
.plusm,.multm an object of class DiscreteDistribution or AbscontDistribution according to argument DClass
.getObjName character
.discretizeP numeric — the probabilities for the grid-values
.makeDd,.makePd, .makeQd a function with args x, y, yleft, yright
.makeD,.makeDNew a function with args x, log = FALSE
.makeP,.makePNew a function with args q, lower.tail = TRUE, log.p = FALSE
.makeQ,.makeQNew a function with args p, lower.tail = TRUE, log.p = FALSE

Author(s)

Peter Ruckdeschel Peter.Ruckdeschel@uni-bayreuth.de

See Also

LatticeDistribution, RtoDPQ, RtoDPQ.d, convpow, operators, plot-methods


[Package distr version 1.9 Index]