Skip to contents

Computes the fixed-grid leave-one-out score $$D_i = 1 - \widehat f_{(-i)}(X_i) / \widehat f(X_i)$$ for observations in data. The grid, bandwidths, and estimator parameters are held fixed when the contribution of observation i is removed.

Usage

compute_Di(
  data,
  b = compute_bi_optim(data, m = rep(1, ncol(data))),
  m = rep(1, ncol(data)),
  estimator = c("GLBFP", "LBFP", "ASH"),
  min_vals = apply(data, 2, min),
  max_vals = apply(data, 2, max)
)

Arguments

data

Numeric matrix or data frame of observations (n x d).

b

Positive numeric vector of bandwidths (length d).

m

Positive integer vector of shifts (length d). Ignored for estimator = "LBFP", where m = 1.

estimator

Character string. One of "GLBFP", "LBFP", or "ASH".

min_vals

Numeric vector of lower grid bounds (length d).

max_vals

Numeric vector of upper grid bounds (length d).

Value

A list with class "glbfp_di" containing the score vector D, fitted densities, leave-one-out densities, self-weights, and metadata.

Examples

x <- as.matrix(ashua[seq_len(80), -3])
b <- c(0.5, 0.5)
out <- compute_Di(x, b = b, m = c(1, 1), estimator = "GLBFP")
summary(out)
#> D_i score summary
#> Method: GLBFP 
#> Observations: 80 
#> Dimension: 2 
#> D_i quantiles:
#>         0%        25%        50%        75%       100% 
#> 0.03556359 0.08769529 1.00000000 1.00000000 1.00000000 
#> D_i mean: 0.6751737 
#> Missing D_i: 0 
#> Density range: 0.0181999999999951 to 0.7725 
#> Median visited cells: 1 
#> Median prefix nodes: 6