Package 'md'

Title: Selecting Bandwidth for Kernel Density Estimator with Minimum Distance Method
Description: Selects bandwidth for the kernel density estimator with minimum distance method as proposed by Devroye and Lugosi (1996). The minimum distance method directly selects the optimal kernel density estimator from countably infinite kernel density estimators and indirectly selects the optimal bandwidth. This package selects the optimal bandwidth from finite kernel density estimators.
Authors: Genzo Kaga
Maintainer: Genzo Kaga <[email protected]>
License: GPL-2 | GPL-3
Version: 1.0.4
Built: 2024-09-17 06:01:52 UTC
Source: CRAN

Help Index


Get 0-1 vector which is used for calculating empirical measure

Description

Get 0-1 vector which is used for calculating empirical measure

Usage

counter(e2, box2)

Arguments

e2

integer

box2

matrix which has 0-1 elements related to Scheffe set

Value

0-1 vector


Calculating delta

Description

Calculating delta

Usage

deltaboxm(ij, box, box2, mu_box2, grid)

Arguments

ij

number order vector

box

matrix which has estimated values of all kernel density estimators

box2

matrix which has 0-1 elements related to Scheffe set

mu_box2

matrix which has values of all empirical measures

grid

length of grid in domain

Value

delta value


Get number order matrix which is used in md

Description

Get number order matrix which is used in md

Usage

dmm(i, prod2)

Arguments

i

integer

prod2

integer which is defined in md

Value

matrix related to number order


Calculating estimated density value on some x with bandwidth h

Description

Calculating estimated density value on some x with bandwidth h

Usage

fhat(x, h, data)

Arguments

x

scalar

h

bandwidth

data

data sample

Value

estimated density value

Examples

fhat(0,0.2,rnorm(100))

Get estimated values of kernel density estimator on domain

Description

Get estimated values of kernel density estimator on domain

Usage

fhatboxm(ij, data_for_d, h, x)

Arguments

ij

number order vector

data_for_d

data sample which is split to be used for kernel density estimator

h

bandwidth

x

scalar

Value

estimated values of kernel density estimator on domain


Kernel function

Description

Kernel function

Usage

ker(x)

Arguments

x

scalar

Value

density


md selects bandwidth for kernel density estimator with minimum distance method. Minimum distance method directly selects optimal kernel density estimator in countably infinite kernel density estimators and indirectly selects optimal bandwidth. md selects optimal bandwidth in countably finite kernel density estimators.

Description

md selects bandwidth for kernel density estimator with minimum distance method. Minimum distance method directly selects optimal kernel density estimator in countably infinite kernel density estimators and indirectly selects optimal bandwidth. md selects optimal bandwidth in countably finite kernel density estimators.

Usage

md(data,hnumber,ds)

Arguments

data

data sample

hnumber

the number of bandwidth which md can select. 60 is enough. Of course, you can take it more.

ds

rate of data split. Minimum distance method has to split data for constructing kernel density estimators and empirical measures.

Value

bandwidth

Examples

# select bandwidth
md(runif(100),20,0.6)

# select bandwidth and plot
data <- rnorm(100)
bandwidth <- md(data,20,0.6)
x <- seq(min(data),max(data),length=100)
plot(x,sapply(x,fhat,bandwidth,data),type="l",ylab="density")

Get number order matrix which is used in md

Description

Get number order matrix which is used in md

Usage

nom(i, length)

Arguments

i

integer

length

the number of grids in domain

Value

matrix related to number order


Calculating Scheffe sets

Description

Calculating Scheffe sets

Usage

scheffe(ij, box)

Arguments

ij

number order vector

box

estimated values of all kernel density estimators

Value

0-1 vector


Auxiliary function which is used in md

Description

Auxiliary function which is used in md

Usage

subcounter(l, data, x)

Arguments

l

integer

data

data sample

x

scalar

Value

integer


Get number order vector which is used in md

Description

Get number order vector which is used in md

Usage

xmm(j)

Arguments

j

integer

Value

vector related to number order


Get number order matrix which is used in md

Description

Get number order matrix which is used in md

Usage

xym(i, length)

Arguments

i

integer

length

the number of grids in domain

Value

matrix related to number order