lpdensity_fn: Supporting Function for 'lpdensity'

View source: R/lpdensity_fn.R

lpdensity_fnR Documentation

Supporting Function for lpdensity

Description

lpdensity_fn implements the local polynomial density estimator. This function is for internal use, and there is no error handling or robustness check.

Usage

lpdensity_fn(
  data,
  grid,
  bw,
  p,
  q,
  v,
  kernel,
  Cweights,
  Pweights,
  massPoints,
  showSE = TRUE
)

Arguments

data

Numeric vector or one dimensional matrix/data frame, the raw data.

grid

Numeric vector or one dimensional matrix/data frame, the grid on which density is estimated.

bw

Numeric vector or one dimensional matrix/data frame, the bandwidth used for estimation. Should be strictly positive, and have the same length as grid.

p

Integer, nonnegative, the order of the local-polynomial used to construct point estimates.

q

Integer, nonnegative, the order of the local-polynomial used to construct confidence interval (a.k.a. the bias correction order).

v

Integer, nonnegative, the derivative of distribution function to be estimated. 0 for the distribution function, 1 (default) for the density funtion, etc.

kernel

String, the kernel function, should be one of "triangular", "uniform" or "epanechnikov".

Cweights

Numeric vector or one dimensional matrix/data frame, the weights used for counterfactual distribution construction. Should have the same length as sample size.

Pweights

Numeric vector or one dimensional matrix/data frame, the weights used in sampling. Should have the same length as sample size, and nonnegative.

massPoints

Boolean, whether whether point estimates and standard errors should be corrected if there are mass points in the data.

showSE

TRUE (default) or FALSE, whether standard errors should be computed.

Details

Recommend: use lpdensity.

Value

grid

grid points.

bw

bandwidth for each grid point.

nh

Effective sample size for each grid point.

f_p

Density estimates on the grid with local polynomial of order p, with the same length as grid.

f_q

Density estimates on the grid with local polynomial of order q, with the same length as grid. This is reported only if q is greater than 0.

se_p

Standard errors corresponding to hat_p.

se_q

Standard errors corresponding to hat_q. This is reported only if q is greater than 0.


lpdensity documentation built on Oct. 6, 2024, 9:06 a.m.