Evaluates the _conditional_ distribution implied by a tramME model, given by a set of covariates and random effects on a selected scale.
# S3 method for tramME
predict(
object,
newdata = model.frame(object),
ranef = NULL,
type = c("lp", "trafo", "distribution", "survivor", "density", "logdensity",
"hazard", "loghazard", "cumhazard", "odds", "logodds", "quantile"),
...
)
A tramME
object.
an optional data frame of observations
Random effects (either in named list format or a numeric vector) or the word "zero". See Details.
The scale on which the predictions are evaluated:
lp: Linear predictor (Xb + Zg). For more information, see Details.
trafo: The prediction evaluated on the scale of the transformation function.
distribution: The prediction evaluated on the scale of the conditional CDF.
survivor: The prediction evaluated on the scale of the (conditional) survivor function.
density, logdensity: The prediction evaluated on the scale of the conditional (log-)PDF.
hazard, loghazard, cumhazard: The prediction evaluated on the hazard/log-hazard/cumulative hazard scale.
odds, logodds: The prediction evaluated on the (log-)odds scale.
quantile: Return the quantiles of the conditional outcome distribution
corresponding to newdata
. For more information, see Details.
Additional arguments, passed to predict.mlt
.
A numeric vector/matrix of the predicted values (depending on the inputs)
or a response
object, when the some of the requested conditonal quantiles
fall outside of the support of the response distribution specified when the model
was set up (only can occur with type = "quantile"
).
When newdata
contains values of the response variable, prediction is only
done for those values. In this case, if random effects vector (ranef
) is not
supplied by the user, the function predicts the random effects from the model
using newdata
.
When no response values are supplied in newdata
, the prediction is done
on a grid of values for each line of the dataset (see predict.mlt
for information on how to control the setup of this grid).
In this case, the user has to specify the vector of random effects to avoid ambiguities.
The linear predictor (type = "lp"
) equals to the shift terms plus the random
effects terms _without the baseline transfromation function_.
The linear predictor (type = "lp"
) and the conditional quantile function
(type = "quantile"
) are special in that they do not return results evaluated
on a grid, even when the response variable in newdata
is missing. The probabilities
for the evaluation of the quantile function can be supplied with the prob
argument
of predict.mlt
.
In the case of type = "quantile"
, when the some of the requested conditonal
quantiles fall outside of the support of the response distribution
(specified when the model was set up), the inversion of the CDF cannot be done exactly
and tramME
returns censored values.
When ranef
is equal to "zero", a vector of zeros with the right size is
used.
# NOT RUN {
data("sleepstudy", package = "lme4")
fit <- BoxCoxME(Reaction ~ Days + (Days | Subject), data = sleepstudy)
predict(fit, type = "trafo") ## evaluate on the transformation function scale
nd <- sleepstudy
nd$Reaction <- NULL
pr <- predict(fit, newdata = nd, ranef = ranef(fit), type = "distribution",
K = 100)
# }
Run the code above in your browser using DataLab