| predict.estimate.mmrm | R Documentation |
Predictions at a single visit from an mmrm model
## S3 method for class 'estimate.mmrm'
predict(object, newdata = NULL, time = NULL, p = coef(object), ...)
object |
(estimate.mmrm) estimate of an mmrm model obtained with
|
newdata |
(data.frame) long-format data with the subject and visit variables, covariates and (optionally) the response. Defaults to the data used to fit the model. |
time |
(integer) index of the visit to predict (default last visit). |
p |
(numeric) parameter vector on the scale of |
... |
additional arguments (not used) |
For each subject in newdata, returns the outcome at visit time if it is
observed, and otherwise the conditional mean given the observed outcomes of
the subject. With O the observed visits of subject i,
E(Y_{it} \mid Y_{iO}) = x_{it}^\top\beta +
\Sigma_{tO}\Sigma_{OO}^{-1}(Y_{iO} - X_{iO}\beta),
where \Sigma is the (group-specific) covariance matrix of all visits
(the marginal mean x_{it}^\top\beta if no outcomes are observed).
This corresponds to predict(fit, newdata, conditional = TRUE) of the mmrm
package.
newdata is first expanded to all subject and visit combinations with
complete_visits().
Named numeric vector (subject IDs) with attributes observed
(logical) and time.
if (requireNamespace("mmrm", quietly = TRUE)) {
data(fev_data, package = "mmrm")
fit <- mmrm::mmrm(
FEV1 ~ ARMCD * AVISIT + us(AVISIT | USUBJID),
data = fev_data, reml = FALSE,
optimizer = "nlminb"
)
e <- estimate(fit, sigma = TRUE)
predict(e, newdata = subset(fev_data, USUBJID %in% c("PT1", "PT2")))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.