CookDistance: Cook's distance for the coefficient estimates

View source: R/CookDistance.R

CookDistanceR Documentation

Cook's distance for the coefficient estimates

Description

CookDistance allows the user to identify those subjects with a greater influence in the estimation of the \beta (tumor growth rate) for the treatment group, based in the calculation of Cook's distances.

Usage

CookDistance(model, cook_thr = NA, label_angle = 0, verbose = TRUE)

Arguments

model

An object of class "lme" representing the linear mixed-effects model fitted by lmmModel().

cook_thr

Numeric value indicating the threshold for the Cook's distance. If not specified, the threshold is set to the 90% percentile of the Cook's distance values.

label_angle

Numeric value indicating the angle for the label of subjects with a Cook's distance greater than cook_thr.

verbose

Logical indicating if the subjects with a Cook's distance greater than cook_thr should be printed to the console.

Details

The identification of the subjects with a greater influence in each estimated \beta representing the tumor growth is based on the calculation of Cook's distances, as described in GaƂecki and Burzykowsk (2013). To compute the Cook's distance for the \beta estimates (i.e., the contribution to each subject to the coefficient of its treatment group), first a matrix containing the leave-one-subject-out estimates or \beta is calculated. Then, the Cook's distances are calculated according to:

D_i \equiv \frac{(\hat{\beta} - \hat{\beta}_{(-i)})[\widehat{Var(\hat{\beta})}]^{-1}(\hat{\beta} - \hat{\beta}_{(-i)})}{rank(X)}

where \hat{\beta}_{(-i)} is the estimate of the parameter vector \beta obtained by fitting the model to the data with the i-th subject excluded. The denominator of the expression is equal to the number of the fixed-effects coefficients, which, under the assumption that the design matrix is of full rank, is equivalent to the rank of the design matrix.

Value

A plot of the Cook's distance value for each subject, indicating those subjects whose Cook's distance is greater than cook_thr.

If saved to a variable, the function returns a vector with the Cook's distances for each subject.

References

  • Andrzej Galecki & Tomasz Burzykowski (2013) Linear Mixed-Effects Models Using R: A Step-by-Step Approach First Edition. Springer, New York. ISBN 978-1-4614-3899-1

Examples

#' # Load the example data
data(grwth_data)
# Fit the model
lmm <- lmmModel(
  data = grwth_data,
  sample_id = "subject",
  time = "Time",
  treatment = "Treatment",
  tumor_vol = "TumorVolume",
  trt_control = "Control",
  drug_a = "DrugA",
  drug_b = "DrugB",
  combination = "Combination"
  ) 
# Calulate Cook's distances for each subject
CookDistance(model = lmm)
# Change the Cook's distance threshold
CookDistance(model = lmm, cook_thr = 0.15)


SynergyLMM documentation built on April 4, 2025, 4:13 a.m.