Compute the residuals (responses minus fitted values) of a fitted progression model for repeated measures.
Usage
# S3 method for class 'pmrm_fit'
residuals(object, ..., data = object$data, adjust = TRUE)Arguments
- object
A fitted model object of class
"pmrm_fit".- ...
Not used.
- data
A
tibbleor data frame with one row per patient visit. This is the new data for making predictions. It must have all the same columns as the original you fit with the model, except that the outcome column can be entirely absent.object$datais an example dataset that will work. It is just like the original data, except that rows with missing responses are removed, and the remaining rows are sorted by patient ID and categorical scheduled visit.- adjust
TRUEorFALSE.adjust = TRUEreturns estimates and inference for covariate-adjustedmu_ijvalues (defined invignette("models", package = "pmrm")) for new data.adjust = FALSEinstead returns inference onmu_ij - W %*% gamma, the non-covariate-adjusted predictions useful in plotting a continuous disease progression trajectory inplot.pmrm_fit().
Value
A numeric vector of residuals corresponding to the
rows of the data supplied in the data argument.
See also
Other predictions:
fitted.pmrm_fit(),
predict.pmrm_fit()
Examples
set.seed(0L)
simulation <- pmrm_simulate_decline_proportional(
visit_times = seq_len(5L) - 1,
gamma = c(1, 2)
)
fit <- pmrm_model_decline_proportional(
data = simulation,
outcome = "y",
time = "t",
patient = "patient",
visit = "visit",
arm = "arm",
covariates = ~ w_1 + w_2
)
str(residuals(fit))
#> num [1:1500] 1.242 -0.314 1.341 1.224 0.347 ...
