Calculate a change-of-parameter for an aster model or the derivative of such a change-of-parameter. Validate certain parameter vectors.
transformSaturated(parm, data, from = c("theta", "phi", "xi", "mu"),
to = c("theta", "phi", "xi", "mu"), differential,
model.type = c("unconditional", "conditional"),
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, model.type = c("unconditional", "conditional"),
tolerance = 8 * .Machine$double.eps)
is.validtheta(data, theta, model.type = c("unconditional", "conditional"),
tolerance = 8 * .Machine$double.eps)
validxi(data, xi, model.type = c("unconditional", "conditional"),
tolerance = 8 * .Machine$double.eps)
is.validxi(data, xi, model.type = c("unconditional", "conditional"),
tolerance = 8 * .Machine$double.eps)
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.
parameter vector to transform,
a numerical vector of length nrow(data$redata)
for transformSaturated
or of length ncol(modmat)
for transformConditional
and transformUnconditional
.
an object of class "asterdata"
produced by
asterdata
or “by hand” such that
is.validasterdata(data)
returns TRUE
. The specification
of the aster model.
the kind of parameter which parm
is. May be abbreviated.
the kind of parameter to which parm
is to be converted.
May be abbreviated.
if not missing a numeric vector of the same length
as parm
. If missing the change-of-parameter is calculated.
If not missing the directional derivative of the change-of-parameter
is calculated (see Details section).
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
.
the offset vector for a canonical affine submodel, a
numerical vector of length nrow(data$redata)
. May be missing,
in which case offset vector equal to zero is used.
conditional canonical parameter vector to validate,
a numerical vector of length nrow(data$redata)
.
conditional canonical parameter vector to validate,
a numerical vector of length nrow(data$redata)
.
which kind of model (see Details section). May be abbreviated.
numeric >= 0. Relative errors smaller
than tolerance
are not considered in checking validity
of xi
for multinomial data.
the “transform” function that will be called to
calculate derivatives, e. g., transform == "saturated"
means the
function transformSaturated
will be called. May be abbreviated.
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
\(\varphi = 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.
There is a difference between conditional and unconditional aster models in the way they treat zero predecessors. For a conditional aster model, if the observed value of the predecessor is zero, then the successor is zero almost surely and can have any parameter value for \(\theta\) or \(\xi\). For an unconditional aster model, if the expected value of the predecessor is zero, then the successor is zero almost surely and can have any parameter value for \(\theta\) or \(\xi\).
Since zero values are not allowed at initial nodes (not
considered valid by the function validasterdata
), the only
way predecessor data can be zero almost surely in an unconditional aster model
is if the delta vector (data$redelta
) is not zero so we have a limiting
model.
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.
asterdata
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
if (FALSE) jack <- jacobian(theta, echinacea, from = "theta", to = "phi")
Run the code above in your browser using DataLab