ZQuadratic-class: ZQuadratic

Description Details Fields Methods Examples

Description

Build piecewise quadratic log-probability density functions

Details

This is an auxiliary Reference Class in this package. Objects of this reference class are created by opt objects, to represent the p.d.f. of transformed, orthogonal parameters. One object is created per p.d.f. parameter. Users of the package needn't interact with these objects directly; instead, they should call opt object methods. PQFA = piecewise quadratic approximation to log-probability density function.

Fields

n

numeric No. points of exact p.d.f. evaluations

x

numeric Univariate z-coordinates of the n points

y

numeric Exact p.d.f. evaluations of the n points

beta0

numeric Intercepts of PQFA

beta1

numeric Slopes of PQFA

beta2

numeric Coeffs. of quadratic terms in PQFA

dx

numeric Distances between adjac. z-coordinates

normct

numeric Normalizing constant of PQFA

pcdf

numeric Partial cdf associated with PQFA

fns

list Auxiliary functions (in R or Fortran)

Methods

cdf(z)

Cumulative distribution function of the transformed z-parameter.

@param z numeric Input (transformed) parameter for the approx. pdf

@result Evaluation(s) of the approximate c.d.f.

iget.coord()

Returns transformed z-coordinates

iget.logd()

Returns exact p.d.f. evaluations

iget.multiply.constant(k)

Multiplies random variable (Z-parameter) by constant

initialize(x = NULL, y = NULL, useFortran = TRUE)

Create a new ZQuadratic object.

@param x numeric Vector of n z-coordinates, n odd, x[(n-1)/2 + 1] = 0

@param y numeric Vector of n exact log-pdf evaluations, made at x

@param useFortran Should Fortran fns. be used instead of R fns.?

invcdf(p)

Inverse c.d.f. of the input probability.

@param p numeric A probability

@result Evaluation(s) of the approximate inverse c.d.f.

iset.operate(operation, operand, operand.name, operand.side, my.name)

Performs arithmetic operation on random variable (Z-parameter)

is.operation.allowed(operation, argclass)

Checks if arithmetic operation is allowed

pdf(z, do.log = FALSE)

Probability density function of the transformed z-parameter

@param z numeric Input (transformed) parameter for the approx. pdf

@param do.log logical Log-transform the approx. pdf evaluation?

@result Evaluation(s) of the approximate pdf

plot.fit(do.log = TRUE)

Plot the piecewise approximation to the p.d.f. @param do.log logical Display log-p.d.f.?

Examples

1
2
3
4
5
6
7
x <- c(-4:4)
y <- dnorm(x, log = TRUE)
zq <- ZQuadratic(x = x, y = y)
do.log <- TRUE #switch to FALSE to see p.d.f.
zq$plot.fit(do.log)
lines(seq(-4, 4, 0.1), dnorm(seq(-4, 4, 0.1),
      log = do.log), ty = "l", lwd = 1, lty = 2)

rtlemos/rcrandom documentation built on May 28, 2019, 9:55 a.m.