Skip to contents

Compute case-level and grouped influence summaries using studentized residuals, leverage, and Cook's distance.

Usage

influence_diagnostics(object, cluster = NULL, outcome = NULL, top_n = 10L)

Arguments

object

A fitted mars object.

cluster

Optional cluster column in object$data.

outcome

Optional outcome column in object$data.

top_n

Number of top influential rows to retain.

Value

A list with row-level influence diagnostics, grouped summaries, thresholds, and top influential rows.

Examples

# \donttest{
fit <- mars(
  data = teacher_expectancy,
  studyID = "study",
  effectID = NULL,
  sample_size = NULL,
  formula = yi ~ 1,
  variance = "vi",
  varcov_type = "univariate",
  structure = "univariate"
)
influence_diagnostics(fit, top_n = 5)
#> $structure
#> [1] "univariate"
#> 
#> $influence
#>    index     fitted         raw studentized   leverage cooks_distance
#> 1      1 0.08370125 -0.05370125 -0.30137138 0.07748087   0.0076282184
#> 2      2 0.08370125  0.03629875  0.18682044 0.06597902   0.0024654602
#> 3      3 0.08370125 -0.22370125 -1.06582986 0.05708169   0.0687699238
#> 4      4 0.08370125  1.09629875  2.78234493 0.01688696   0.1329749569
#> 5      5 0.08370125  0.17629875  0.45167476 0.01720287   0.0035709900
#> 6      6 0.08370125 -0.14370125 -0.87858986 0.09064969   0.0769497985
#> 7      7 0.08370125 -0.10370125 -0.63402974 0.09064969   0.0400732321
#> 8      8 0.08370125 -0.40370125 -1.58893746 0.03967312   0.1043015731
#> 9      9 0.08370125  0.18629875  0.89787448 0.05833025   0.0499374588
#> 10    10 0.08370125  0.71629875  2.54603591 0.03259368   0.2184004511
#> 11    11 0.08370125  0.45629875  1.39266016 0.02423924   0.0481798973
#> 12    12 0.08370125  0.09629875  0.37526470 0.03892040   0.0057028683
#> 13    13 0.08370125 -0.10370125 -0.32850500 0.02606337   0.0028879110
#> 14    14 0.08370125  0.14629875  0.46205653 0.02591142   0.0056791457
#> 15    15 0.08370125 -0.26370125 -1.29521503 0.06044566   0.1079262177
#> 16    16 0.08370125 -0.14370125 -0.68466798 0.05708169   0.0283780668
#> 17    17 0.08370125  0.21629875  1.14877901 0.06996009   0.0992708561
#> 18    18 0.08370125 -0.01370125 -0.08673841 0.09655771   0.0008040989
#> 19    19 0.08370125 -0.15370125 -0.71314420 0.05429259   0.0291970160
#>    influence_score flagged cluster
#> 1       0.08733967   FALSE       1
#> 2       0.04965340   FALSE       2
#> 3       0.26224020   FALSE       3
#> 4       0.36465731    TRUE       4
#> 5       0.05975776   FALSE       5
#> 6       0.27739827   FALSE       6
#> 7       0.20018300   FALSE       7
#> 8       0.32295754   FALSE       8
#> 9       0.22346691   FALSE       9
#> 10      0.46733334    TRUE      10
#> 11      0.21949920   FALSE      11
#> 12      0.07551734   FALSE      12
#> 13      0.05373929   FALSE      13
#> 14      0.07536011   FALSE      14
#> 15      0.32852126   FALSE      15
#> 16      0.16845791   FALSE      16
#> 17      0.31507278   FALSE      17
#> 18      0.02835664   FALSE      18
#> 19      0.17087134   FALSE      19
#> 
#> $by_cluster
#>    study n max_abs_studentized max_leverage     cook_sum     cook_max n_flagged
#> 1      1 1          0.30137138   0.07748087 0.0076282184 0.0076282184         0
#> 2      2 1          0.18682044   0.06597902 0.0024654602 0.0024654602         0
#> 3      3 1          1.06582986   0.05708169 0.0687699238 0.0687699238         0
#> 4      4 1          2.78234493   0.01688696 0.1329749569 0.1329749569         1
#> 5      5 1          0.45167476   0.01720287 0.0035709900 0.0035709900         0
#> 6      6 1          0.87858986   0.09064969 0.0769497985 0.0769497985         0
#> 7      7 1          0.63402974   0.09064969 0.0400732321 0.0400732321         0
#> 8      8 1          1.58893746   0.03967312 0.1043015731 0.1043015731         0
#> 9      9 1          0.89787448   0.05833025 0.0499374588 0.0499374588         0
#> 10    10 1          2.54603591   0.03259368 0.2184004511 0.2184004511         1
#> 11    11 1          1.39266016   0.02423924 0.0481798973 0.0481798973         0
#> 12    12 1          0.37526470   0.03892040 0.0057028683 0.0057028683         0
#> 13    13 1          0.32850500   0.02606337 0.0028879110 0.0028879110         0
#> 14    14 1          0.46205653   0.02591142 0.0056791457 0.0056791457         0
#> 15    15 1          1.29521503   0.06044566 0.1079262177 0.1079262177         0
#> 16    16 1          0.68466798   0.05708169 0.0283780668 0.0283780668         0
#> 17    17 1          1.14877901   0.06996009 0.0992708561 0.0992708561         0
#> 18    18 1          0.08673841   0.09655771 0.0008040989 0.0008040989         0
#> 19    19 1          0.71314420   0.05429259 0.0291970160 0.0291970160         0
#> 
#> $by_outcome
#> NULL
#> 
#> $thresholds
#>    n p cooks_distance  leverage abs_studentized
#> 1 19 1      0.2105263 0.1052632               2
#> 
#> $top
#>    index     fitted        raw studentized   leverage cooks_distance
#> 10    10 0.08370125  0.7162988    2.546036 0.03259368     0.21840045
#> 4      4 0.08370125  1.0962988    2.782345 0.01688696     0.13297496
#> 15    15 0.08370125 -0.2637012   -1.295215 0.06044566     0.10792622
#> 8      8 0.08370125 -0.4037012   -1.588937 0.03967312     0.10430157
#> 17    17 0.08370125  0.2162988    1.148779 0.06996009     0.09927086
#>    influence_score flagged cluster
#> 10       0.4673333    TRUE      10
#> 4        0.3646573    TRUE       4
#> 15       0.3285213   FALSE      15
#> 8        0.3229575   FALSE       8
#> 17       0.3150728   FALSE      17
#> 
#> attr(,"class")
#> [1] "mars_influence_diagnostics"
# }