Math: Math Utility Functions

Description Usage Arguments Details Value Author(s) See Also

Description

These are utility functions for math.

Usage

1
2
3
4
GaussHermiteQuadRule(N)
Hermite(x, N, prob=TRUE)
logadd(x, add=TRUE)
partial(Model, parm, Data, Interval=1e-6, Method="simple")

Arguments

N

This required argument accepts a positive integer that indicates the number of nodes.

x

This is a numeric vector.

add

Logical. This defaults to TRUE, in which case log(x+y) is performed. Otherwise, log(x-y) is performed.

Model

This is a model specification function. For more information, see LaplacesDemon.

parm

This is a vector parameters.

prob

Logical. This defaults to TRUE, which uses the probabilist's kernel for the Hermite polynomial. Otherwise, FALSE uses the physicist's kernel.

Data

This is a list of data. For more information, see LaplacesDemon.

Interval

This is the interval of numeric differencing.

Method

This accepts a quoted string, and defaults to "simple", which is finite-differencing. Alternatively Method="Richardson" uses Richardson extrapolation, which is more accurate, but takes longer to calculate. Another method called automatic differentiation is currently unsupported, but is even more accurate, and takes even longer to calculate.

Details

The GaussHermiteQuadRule function returns nodes and weights for univariate Gauss-Hermite quadrature. The nodes and weights are obtained from a tridiagonal eigenvalue problem. Weights are calculated from the physicist's (rather than the probabilist's) kernel. This has been adapted from the GaussHermite function in the pracma package. The GaussHermiteCubeRule function is a multivariate version. This is used in the IterativeQuadrature function.

The Hermite function evaluates a Hermite polynomial of degree N at x, using either the probabilist's (prob=TRUE) or physicist's (prob=FALSE) kernel. This function was adapted from the hermite function in package EQL.

The logadd function performs addition (or subtraction) when the terms are logarithmic. The equations are:

log(x+y) = log(x) + log(1 + exp(log(y) - log(x)))

log(x-y) = log(x) + log(1 - exp(log(y) - log(x)))

The partial function estimates partial derivatives of parameters in a model specification with data, using either forward finite-differencing or Richardson extrapolation. In calculus, a partial derivative of a function of several variables is its derivative with respect to one of those variables, with the others held constant. Related functions include Jacobian which returns a matrix of first-order partial derivatives, and Hessian, which returns a matrix of second-order partial derivatives of the model specification function with respect to its parameters. The partial function is not intended to be called by the user, but is used by other functions. This is essentially the grad function in the numDeriv package, but defaulting to forward finite-differencing with a smaller interval.

Value

logadd returns the result of log(x+y) or log(x-y).

partial returns a vector of partial derivatives.

Author(s)

Statisticat, LLC. [email protected]

See Also

GaussHermiteCubeRule, Hessian, IterativeQuadrature, Jacobian, LaplaceApproximation, LaplacesDemon, and VariationalBayes.


LaplacesDemon documentation built on July 1, 2018, 9:02 a.m.