df.jones: \insertCitejones1991;textualWData kernel density estimator

View source: R/df.jones.R

df.jonesR Documentation

\insertCitejones1991;textualWData kernel density estimator

Description

This function computes \insertCitejones1991;textualWData kernel density estimator given a sample and the corresponding biased function.

Usage

df.jones(
  y,
  w = function(y) {
     ifelse(y >= 0, y, NA)
 },
  y.seq,
  bw = "bw.f.BGM.rt",
  kernel = c("gaussian", "epanechnikov", "rectangular", "triangular", "biweight",
    "cosine", "optcosine"),
  from,
  to,
  nb = 512L,
  plot = TRUE,
  ...
)

Arguments

y

A numeric vector containing the biased sample.

w

A function representing the bias function applied to the data points. It must be evaluable and positive in each point of the sample y. By default, it is set to the length-biased function.

y.seq

A numeric vector specifying the points where the density is estimated. Alternatively, from, to and nb can be used to define the evaluation points.

bw

The smoothing bandwidth to be used in the density estimation. bw can also be a character string giving a rule to choose the bandwidth. In this case, options available are bw.f.BGM.rt, bw.f.BGM.cv, bw.f.BGM.boot1 and bw.f.BGM.boot2. Default is bw.f.BGM.rt.

kernel

A character string specifying the kernel function. Available options: "gaussian", "epanechnikov", "rectangular", "triangular", "biweight", "cosine" and "optcosine".

from

Numeric value specifying the lower bound of the grid where the estimator is computed when y.seq is not provided. Default is computed based on the range of input data.

to

Numeric value specifying the upper bound of the grid where the estimator is computed when y.seq is not provided. Default is computed based on the range of input data.

nb

An integer specifying the number of points at which the estimator is computed when y.seq is not provided. Default is 512.

plot

A logical value indicating whether to plot the density estimation. Default is TRUE.

...

Additional arguments to be passed to bandwidth selection functions.

Details

\insertCite

jones1991;textualWData kernel density estimator is expressed as

\widehat{f}_{\mathrm{J}, h_{f}}(y)=\frac{\widehat{\mu}_w}{n}\sum_{i=1}^{n} \frac{1}{w(Y_i)} K_{h_{f}}(y-Y_i),\quad \text{where}\quad \widehat{\mu}_w=n \left(\sum_{i=1}^{n} \frac{1}{w(Y_i)}\right)^{-1},

h_{f} is the bandwidth, K is the kernel density function and K_{h_{f}}(u)=1/h_{f} K\left(u / h_{f}\right).

Value

A list with the following components:

y.seq

The points where the density is estimated.

f.hat

The estimated density values.

bw

The bandwidth value.

n

The sample size after removal of NaN, Na and Inf.

call

The call which produced the result.

has.na

Logical; indicates whether the original vector y contains any NaN, Na or Inf.

References

\insertAllCited

See Also

bw.f.BGM.rt, bw.f.BGM.cv, bw.f.BGM.boot1 , bw.f.BGM.boot2

Examples

# Rule of thumb
df.jones(y = shrub.data$Width, kernel = "epanechnikov", bw = "bw.f.BGM.rt")
# Cross Validation
df.jones(y = shrub.data$Width, kernel = "epanechnikov", bw = "bw.f.BGM.cv")
# Bootstrap
df.jones(y = shrub.data$Width, kernel = "epanechnikov", bw = "bw.f.BGM.boot1", bw0 = "RT")
df.jones(y = shrub.data$Width, kernel = "epanechnikov", bw = "bw.f.BGM.boot1", bw0 = "PI")

df.jones(y = shrub.data$Width, kernel = "epanechnikov", bw = "bw.f.BGM.boot2", nh = 50L)


WData documentation built on Nov. 2, 2026, 1:10 a.m.