Leave-one-out D_i diagnostics
Source:vignettes/GLBFP_leave_one_out_scores.Rmd
GLBFP_leave_one_out_scores.RmdThis vignette documents a feature of the GitHub development version. The functions described here are not included in the CRAN 0.5.2 release.
The function compute_Di() computes fixed-grid
leave-one-out self-support scores:
The single-grid LBFP case is developed by Nicosia, Duchesne and Carbon
(2026). The bandwidths, grid origin and estimator parameters are
held fixed. Only the contribution of observation i is
removed. The result is a diagnostic for the chosen estimator and grid,
not an estimated outlier probability or a standalone model-selection
criterion.
The project-specific replication package for the article uses a
separate internal R package, LOOLBFP, for the reported
single-grid calculations. In an audit comparison, LOOLBFP
and compute_Di(..., estimator = "LBFP") agreed to
floating-point precision when given equivalent fixed grids. The packages
use different default grid anchors, however, so their default calls need
not produce identical numerical scores. Use LOOLBFP for
exact reproduction of the submitted article results.
library(GLBFP)
x <- cbind(rnorm(120), rnorm(120))
b <- c(0.7, 0.7)
scores <- compute_Di(x, b = b, estimator = "LBFP")
scores
#> Leave-one-out D_i scores
#> Method: LBFP
#> Observations: 120
#> Dimension: 2
#> Bandwidths (b): 0.7, 0.7
#> D_i range: 0.0293371467224842 to 6.88736140525724
summary(scores)
#> D_i score summary
#> Method: LBFP
#> Observations: 120
#> Dimension: 2
#> D_i quantiles:
#> 0% 25% 50% 75% 100%
#> 0.02933715 0.06097744 0.09812679 0.22520567 6.88736141
#> D_i mean: 0.2481551
#> Missing D_i: 0
#> Density range: 0.00238935651742033 to 0.252178782675279
#> Median visited cells: 4
#> Median prefix nodes: 6The output can be converted to a data frame.
score_tbl <- as.data.frame(scores)
head(score_tbl)
#> observation D D_positive density density_loo self_weight visited
#> 1 1 0.06431721 0.06431721 0.11365940 0.106349147 0.4819541 4
#> 2 2 0.30127894 0.30127894 0.04557880 0.031846864 0.8230425 4
#> 3 3 1.46627053 1.46627053 0.01109168 -0.005171722 0.9537536 4
#> 4 4 0.09362358 0.09362358 0.09932247 0.090023546 0.5908884 4
#> 5 5 0.10162642 0.10162642 0.11230308 0.100890118 0.7205182 3
#> 6 6 0.27144345 0.27144345 0.03427144 0.024968679 0.5592367 4
#> prefix_nodes
#> 1 6
#> 2 6
#> 3 6
#> 4 6
#> 5 6
#> 6 6The S3 plot method supports an index plot and a density-versus-score plot.
plot(scores)
plot(scores, type = "density")
The development interface also supports ASH and GLBFP as software extensions of the fixed-grid deletion diagnostic.
m <- c(2, 2)
ash_scores <- compute_Di(x, b = b, m = m, estimator = "ASH")
glbfp_scores <- compute_Di(x, b = b, m = m, estimator = "GLBFP")
c(
LBFP_mean = mean(scores$D),
ASH_mean = mean(ash_scores$D),
GLBFP_mean = mean(glbfp_scores$D)
)
#> LBFP_mean ASH_mean GLBFP_mean
#> 0.2481551 0.2654893 0.2296954Interpretation depends on the chosen estimator, bandwidth and grid. Large positive values indicate observations whose removal substantially decreases their own fitted support under the fixed-grid estimator.