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.08370128 -0.05370128 -0.30137140 0.07748085   0.0076282176
#> 2      2 0.08370128  0.03629872  0.18682016 0.06597902   0.0024654527
#> 3      3 0.08370128 -0.22370128 -1.06582956 0.05708170   0.0687698934
#> 4      4 0.08370128  1.09629872  2.78234449 0.01688697   0.1329750145
#> 5      5 0.08370128  0.17629872  0.45167461 0.01720288   0.0035709903
#> 6      6 0.08370128 -0.14370128 -0.87858944 0.09064966   0.0769496905
#> 7      7 0.08370128 -0.10370128 -0.63402950 0.09064966   0.0400731836
#> 8      8 0.08370128 -0.40370128 -1.58893713 0.03967313   0.1043015704
#> 9      9 0.08370128  0.18629872  0.89787390 0.05833025   0.0499373993
#> 10    10 0.08370128  0.71629872  2.54603515 0.03259370   0.2184004330
#> 11    11 0.08370128  0.45629872  1.39265980 0.02423925   0.0481799030
#> 12    12 0.08370128  0.09629872  0.37526445 0.03892041   0.0057028630
#> 13    13 0.08370128 -0.10370128 -0.32850505 0.02606338   0.0028879136
#> 14    14 0.08370128  0.14629872  0.46205632 0.02591144   0.0056791442
#> 15    15 0.08370128 -0.26370128 -1.29521460 0.06044566   0.1079261528
#> 16    16 0.08370128 -0.14370128 -0.68466785 0.05708170   0.0283780594
#> 17    17 0.08370128  0.21629872  1.14877819 0.06996008   0.0992707047
#> 18    18 0.08370128 -0.01370128 -0.08673857 0.09655766   0.0008041015
#> 19    19 0.08370128 -0.15370128 -0.71314407 0.05429260   0.0291970100
#>    influence_score flagged cluster
#> 1       0.08733967   FALSE       1
#> 2       0.04965333   FALSE       2
#> 3       0.26224014   FALSE       3
#> 4       0.36465739    TRUE       4
#> 5       0.05975776   FALSE       5
#> 6       0.27739807   FALSE       6
#> 7       0.20018288   FALSE       7
#> 8       0.32295754   FALSE       8
#> 9       0.22346677   FALSE       9
#> 10      0.46733332    TRUE      10
#> 11      0.21949921   FALSE      11
#> 12      0.07551730   FALSE      12
#> 13      0.05373931   FALSE      13
#> 14      0.07536010   FALSE      14
#> 15      0.32852116   FALSE      15
#> 16      0.16845789   FALSE      16
#> 17      0.31507254   FALSE      17
#> 18      0.02835668   FALSE      18
#> 19      0.17087133   FALSE      19
#> 
#> $by_cluster
#>    study n max_abs_studentized max_leverage     cook_sum     cook_max n_flagged
#> 1      1 1          0.30137140   0.07748085 0.0076282176 0.0076282176         0
#> 2      2 1          0.18682016   0.06597902 0.0024654527 0.0024654527         0
#> 3      3 1          1.06582956   0.05708170 0.0687698934 0.0687698934         0
#> 4      4 1          2.78234449   0.01688697 0.1329750145 0.1329750145         1
#> 5      5 1          0.45167461   0.01720288 0.0035709903 0.0035709903         0
#> 6      6 1          0.87858944   0.09064966 0.0769496905 0.0769496905         0
#> 7      7 1          0.63402950   0.09064966 0.0400731836 0.0400731836         0
#> 8      8 1          1.58893713   0.03967313 0.1043015704 0.1043015704         0
#> 9      9 1          0.89787390   0.05833025 0.0499373993 0.0499373993         0
#> 10    10 1          2.54603515   0.03259370 0.2184004330 0.2184004330         1
#> 11    11 1          1.39265980   0.02423925 0.0481799030 0.0481799030         0
#> 12    12 1          0.37526445   0.03892041 0.0057028630 0.0057028630         0
#> 13    13 1          0.32850505   0.02606338 0.0028879136 0.0028879136         0
#> 14    14 1          0.46205632   0.02591144 0.0056791442 0.0056791442         0
#> 15    15 1          1.29521460   0.06044566 0.1079261528 0.1079261528         0
#> 16    16 1          0.68466785   0.05708170 0.0283780594 0.0283780594         0
#> 17    17 1          1.14877819   0.06996008 0.0992707047 0.0992707047         0
#> 18    18 1          0.08673857   0.09655766 0.0008041015 0.0008041015         0
#> 19    19 1          0.71314407   0.05429260 0.0291970100 0.0291970100         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.08370128  0.7162987    2.546035 0.03259370      0.2184004
#> 4      4 0.08370128  1.0962987    2.782344 0.01688697      0.1329750
#> 15    15 0.08370128 -0.2637013   -1.295215 0.06044566      0.1079262
#> 8      8 0.08370128 -0.4037013   -1.588937 0.03967313      0.1043016
#> 17    17 0.08370128  0.2162987    1.148778 0.06996008      0.0992707
#>    influence_score flagged cluster
#> 10       0.4673333    TRUE      10
#> 4        0.3646574    TRUE       4
#> 15       0.3285212   FALSE      15
#> 8        0.3229575   FALSE       8
#> 17       0.3150725   FALSE      17
#> 
#> attr(,"class")
#> [1] "mars_influence_diagnostics"
# }