Learn R Programming

aster2 (version 0.2-1)

Transform: Change-of-Parameter Functions for Aster Models

Description

Calculate a change-of-parameter for a saturated aster model or the derivative of such a change-of-parameter. Validate certain parameter vectors.

Usage

transformSaturated(parm, data, from = c("theta", "phi", "xi", "mu"), to = c("theta", "phi", "xi", "mu"), differential, tolerance = 8 * .Machine$double.eps) transformConditional(parm, modmat, data, from = "beta", to = c("theta", "phi", "xi", "mu"), differential, offset, tolerance = 8 * .Machine$double.eps) transformUnconditional(parm, modmat, data, from = c("beta", "tau"), to = c("beta", "theta", "phi", "xi", "mu", "tau"), differential, offset, tolerance = 8 * .Machine$double.eps) jacobian(parm, data, transform = c("saturated", "conditional", "unconditional"), from = c("beta", "theta", "phi", "xi", "mu", "tau"), to = c("beta", "theta", "phi", "xi", "mu", "tau"), modmat, offset, tolerance = 8 * .Machine$double.eps) validtheta(data, theta, tolerance = 8 * .Machine$double.eps) is.validtheta(data, theta, tolerance = 8 * .Machine$double.eps) validxi(data, xi, tolerance = 8 * .Machine$double.eps) is.validxi(data, xi, tolerance = 8 * .Machine$double.eps)

Arguments

parm
parameter vector to transform, a numerical vector of length nrow(data$redata) for transformSaturated or of length ncol(modmat) for transformConditional and transformUnconditional.
data
an object of class "asterdata" produced by asterdata or “by hand” such that is.validasterdata(data) returns TRUE. The specification of the aster model.
from
the kind of parameter which parm is. May be abbreviated.
to
the kind of parameter to which parm is to be converted. May be abbreviated.
differential
if not missing a numeric vector of the same length as parm. If missing the change-of-parameter is calculated. If not missing the derivative of the change-of-parameter is calculated.
modmat
the model matrix for a canonical affine submodel, a numerical matrix having nrow(data$redata) rows and length(beta) columns for transformConditional or length(parm) columns for transformUnconditional.
offset
the offset vector for a canonical affine submodel, a a numerical vector of length nrow(data$redata). May be missing, in which case offset vector equal to zero is used.
theta
conditional canonical parameter vector to validate, a numerical vector of length nrow(data$redata).
xi
conditional canonical parameter vector to validate, a numerical vector of length nrow(data$redata).
tolerance
numeric >= 0. Relative errors smaller than tolerance are not considered in checking validity of xi for multinomial data.
transform
the “transform” function that will be called to calculate derivatives, e. g., transform == "saturated" means the function transformSaturated will be called. May be abbreviated.

Value

a numeric vector of the same length as parm. The new parameter if deriv == FALSE or the transform of the differential if deriv = TRUE. See details.

Details

If differential is missing, the returned value is a new parameter vector of the specified type. If differential is not missing, the returned value is the derivative evaluated at parm and differential, that is, if $f$ is the change-of variable function and $psi$ is the from parameter, then $f(psi)$ is calculated when the differential is missing and $f'(psi)(delta)$ is calculated when the differential $delta$ is not missing, where the latter is defined by $$f(\psi + \delta) \approx f(\psi) + f'(\psi)(\delta)$$ for small $delta$.

The kinds of parameters are "theta" the conditional canonical parameter for the saturated model, "phi" the unconditional canonical parameter for the saturated model, "xi" the conditional mean value parameter for the saturated model, "mu" the unconditional mean value parameter for the saturated model, "beta" the regression coefficient parameter for a canonical affine submodel ($theta = a + M beta$ for a conditional canonical affine submodel or $phi = a + M beta$ for an unconditional canonical affine submodel, where $a$ is the offset vector and $M$ is the model matrix), "tau" the mean value parameter for an unconditional canonical affine submodel ($tau = M^T mu$, where $M$ is the model matrix).

Only the conditional canonical parameter vector $theta$ and the conditional mean value parameter vector $xi$ can be checked directly. (To check the validity of another parameter, transform to one of these and check that.) This means that in conversions to these parameters the output vector is checked rather than the input vector, and conversions (apparently) not involving these parameters (which do go through these parameters inside the transformation function) a conversion to one of these parameters is what is checked rather than the input vector.

The function jacobian turns the derivative considered as a linear transformation calculated by the “transform” functions into the matrix that represents the linear transformation (sometimes called the Jacobian matrix of the transformation). The arguments modmat and offset are only used if transform == "conditional" or transform == "unconditional", and (as with the “transform” functions) the argument offset may be missing, in which case the zero vector is used. Not all of the candidate values for from and to arguments for the jacobian function are valid: the value must be valid for the “transform” function that will be called.

See Also

asterdata

Examples

Run this code
data(echinacea)
theta <- rnorm(nrow(echinacea$redata), 0, 0.1)
phi <- transformSaturated(theta, echinacea, from = "theta", to = "phi")
## rarely (if ever) want jacobian for unsaturated model transform
## result here is 5130 by 5130 matrix
## Not run: jack <- jacobian(theta, echinacea, from = "theta", to = "phi")

Run the code above in your browser using DataLab