Note that model.type
need have nothing to do with the type
of the fitted aster model, which is object$type
.Whether the
fitted model is conditional or unconditional, one typically wants
unconditional mean value parameters, because conditional mean
value parameters for hypothetical individuals depend on the hypothetical
data x
, which usually makes no scientific sense.
If one does ask for conditional mean value parameters, generally
the data should satisfy all(x == 1)
and all(root == 1)
,
so that the mean value parameters
are per unit of predecessor variable, that is we predict
$\psi''(\theta_{i j})$ rather than this multiplied
by $X_{i p(j)}$, where $p(j)$ is the mathematical
function defined by the R expression pred[j]
.
Similarly, if object$type == "conditional"
, then the conditional
canonical parameters are a linear function of the regression coefficients
$\theta = M \beta$, where $M$ is the model matrix,
but one can predict either $\theta$ or the unconditional
canonical parameters $\varphi$,
as selected by model.type
.
Similarly, if object$type == "unconditional"
,
so $\varphi = M \beta$, one can predict either
$\theta$ or $\varphi$
as selected by model.type
.
The specification of the prediction model is confusing because there
are so many possibilities. First the usual case.
The fit was done using a formula, found in object$formula
.
A data frame newdata
that has the same variables as object$data
,
the data frame used in the fit, but may have different rows (representing
hypothetical individuals) is supplied.
But newdata
must specify all nodes
of the graphical model for each (hypothetical, new) individual,
just like object$data
did for real observed individuals.
Hence newdata
is typically constructed using reshape
.
See also the details section of aster
.
In this usual case we need varvar
and idvar
to
tell us what rows of newdata
correspond to which individuals and
nodes (the same role they played in the original fit by aster
).
If we are predicting canonical parameters, then we do not need root
or
x
.
If we are predicting unconditional mean value parameters, then
we also need root
but not x
.
If we are predicting conditional mean value parameters, then
we also need both root
and x
.
In the usual case, these are found in newdata
and
not supplied as arguments to predict
. Moreover, x
is not named "x"
but is the response in out$formula
.
The next case, predict(object)
with no other arguments,
is often used with linear models (predict.lm
),
but we expect will be little used for aster models. As for linear
models, this predicts the observed data. In this case
modmat
, x
, and root
are found in object
and nothing is supplied as an argument to predict.aster
, except
perhaps amat
if one wants a function of predictions for the observed
data.
The final case, also perhaps little used, is a fail-safe mode for problems
in which the R formula language just cannot be bludgeoned into doing what
you want. This is the same reason aster.default
exists.
Then a model matrix can be constructed by hand, and the function
predict.aster
is used instead of predict.aster.formula
.
Note that it is possible to use a constructed by hand
model matrix even if object
was produced by aster.formula
.
Simply explicitly call predict.aster
rather than predict
to override the R method dispatch (which would
call predict.aster.formula
in this case).