Skip to contents

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 tibble or 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$data is 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

TRUE or FALSE. adjust = TRUE returns estimates and inference for covariate-adjusted mu_ij values (defined in vignette("models", package = "pmrm")) for new data. adjust = FALSE instead returns inference on mu_ij - W %*% gamma, the non-covariate-adjusted predictions useful in plotting a continuous disease progression trajectory in plot.pmrm_fit().

Value

A numeric vector of residuals corresponding to the rows of the data supplied in the data argument.

See also

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 ...