--- title: "Leave-one-out D_i diagnostics" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Leave-one-out D_i diagnostics} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set(collapse = TRUE, comment = "#>") set.seed(20260607) ``` The function `compute_Di()` computes fixed-grid leave-one-out self-support scores: \[ D_i = 1 - \frac{\widehat f_{(-i)}(X_i)}{\widehat f(X_i)}. \] 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 a standalone model-selection criterion. ```{r} library(GLBFP) x <- cbind(rnorm(120), rnorm(120)) b <- c(0.7, 0.7) m <- c(2, 2) scores <- compute_Di(x, b = b, m = m, estimator = "GLBFP") scores summary(scores) ``` The output can be converted to a data frame. ```{r} score_tbl <- as.data.frame(scores) head(score_tbl) ``` The S3 plot method supports an index plot and a density-versus-score plot. ```{r} plot(scores) plot(scores, type = "density") ``` The same interface supports `LBFP` and `ASH`. ```{r} lbfp_scores <- compute_di(x, b = b, estimator = "LBFP") ash_scores <- compute_di(x, b = b, m = m, estimator = "ASH") c( LBFP_mean = mean(lbfp_scores$D), ASH_mean = mean(ash_scores$D), GLBFP_mean = mean(scores$D) ) ``` Interpretation 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.