diff --git a/R/lpcde/DESCRIPTION b/R/lpcde/DESCRIPTION index 9bf1fbb..29a571e 100644 --- a/R/lpcde/DESCRIPTION +++ b/R/lpcde/DESCRIPTION @@ -7,7 +7,7 @@ Authors@R: person(given = "Rajita", role = c("aut", "cre"), email = "rchandak@princeton.edu" ) Maintainer: Rajita Chandak -Description: Tools for estimation and inference of conditional densities, derivatives and functions. This is the companion software for Cattaneo, Chandak, Jansson and Ma (2024). +Description: Tools for estimation and inference of conditional densities, derivatives and functions. This is the companion software for Cattaneo, Chandak, Jansson and Ma (2024) . Depends: R (>= 3.3.0) License: GPL-2 Encoding: UTF-8 @@ -23,7 +23,10 @@ Imports: mvtnorm, combinat, Matrix, + Rdpack, stats +RdMacros: + Rdpack LinkingTo: Rcpp, RcppArmadillo diff --git a/R/lpcde/NAMESPACE b/R/lpcde/NAMESPACE index 11863ab..f3e714a 100644 --- a/R/lpcde/NAMESPACE +++ b/R/lpcde/NAMESPACE @@ -14,4 +14,5 @@ export(lpbwcde) export(lpcde) export(poly_base) importFrom(Rcpp,evalCpp) +importFrom(Rdpack,reprompt) useDynLib(lpcde, .registration = TRUE) diff --git a/R/lpcde/R/lpbwcde.R b/R/lpcde/R/lpbwcde.R index 0c8c84d..7b22638 100644 --- a/R/lpcde/R/lpbwcde.R +++ b/R/lpcde/R/lpbwcde.R @@ -3,7 +3,7 @@ #' #' @description \code{\link{lpbwcde}} implements the bandwidth selection methods for local #' polynomial based conditionaldensity (and derivatives) estimation proposed and studied -#' in Cattaneo, Chandak, Jansson and Ma (2021). +#' in \insertCite{bernoulli}{lpcde}. #' #' Companion command: \code{\link{lpcde}} for estimation and robust bias-corrected inference. #' @@ -66,6 +66,9 @@ #' # Display bandwidths for a subset of y_grid points #' summary(bw1, y_grid=bw1$BW[2:5, "y_grid"]) #' +#' @references +#' \insertRef{bernoulli}{lpcde} +#' #' @export #' lpbwcde <- function(y_data, x_data, x, y_grid=NULL, p=NULL, q=NULL, grid_spacing="", ng=NULL, @@ -279,7 +282,7 @@ lpbwcde <- function(y_data, x_data, x, y_grid=NULL, p=NULL, q=NULL, grid_spacing data_min=min(y_data), data_max=max(y_data), grid_min=min(y_grid), grid_max=max(y_grid))) - class(Result) <- c("lpbwcde", "lpcde") + class(Result) <- c("lpbwcde") return (Result) } diff --git a/R/lpcde/R/lpcde.R b/R/lpcde/R/lpcde.R index 153055e..d510269 100644 --- a/R/lpcde/R/lpcde.R +++ b/R/lpcde/R/lpcde.R @@ -5,7 +5,7 @@ #' @title Local Polynomial Conditional Density Estimation #' @description \code{\link{lpcde}} implements the local polynomial regression based #' conditional density (and derivatives). The estimator proposed in -#' Chandak, Cattaneo, Jansson and Ma. +#' \insertCite{bernoulli}{lpcde}. #' Robust bias-corrected inference methods, both pointwise (confidence intervals) and #' uniform (confidence bands), are also implemented. #' @param x_data Numeric matrix/data frame, the raw data of covariates. @@ -89,6 +89,11 @@ #' \code{\link{plot.lpcde}}, \code{\link{print.lpcde}}, #' \code{\link{summary.lpcde}}, \code{\link{vcov.lpcde}} #' +#' @references +#' \insertRef{bernoulli}{lpcde}\cr +#' \insertRef{JASA}{lpcde}\cr +#' \insertRef{rbc}{lpcde}\cr +#' \insertRef{lpdensitypaper}{lpcde} #' @export lpcde = function(x_data, y_data, y_grid=NULL, x=NULL, bw=NULL, p=NULL, q=NULL, p_RBC=NULL, q_RBC=NULL, mu=NULL, nu=NULL, rbc = TRUE, ng=NULL, diff --git a/R/lpcde/R/lpcde_fns.R b/R/lpcde/R/lpcde_fns.R index 892741f..91e36ce 100644 --- a/R/lpcde/R/lpcde_fns.R +++ b/R/lpcde/R/lpcde_fns.R @@ -23,6 +23,7 @@ # choose from "ustat" and "asymp". #' @return conditional density estimate at all grid points. #' @keywords internal +#' @importFrom Rdpack reprompt lpcde_fn = function(y_data, x_data, y_grid, x, p, q, p_RBC, q_RBC, bw, mu, nu, kernel_type, rbc = FALSE){ sd_y = stats::sd(y_data) diff --git a/R/lpcde/inst/references.bib b/R/lpcde/inst/references.bib new file mode 100644 index 0000000..dcdc52e --- /dev/null +++ b/R/lpcde/inst/references.bib @@ -0,0 +1,39 @@ +@article{bernoulli, + title={Local Polynomial Conditional Density Estimators}, + author={Cattaneo, Matias D. and Chandak, Rajita and Jansson, Michael and Ma, Xinwei}, + journal={Bernoulli}, + volume={}, number={}, pages={}, year={2024} +} + +@article{JASA, + author = {Calonico, Sebastian and Matias D. Cattaneo and + Max H. Farrell}, + journal = {Journal of the American Statistical Association}, + number = {522}, + pages = {767--779}, + title = {On the Effect of Bias Estimation on Coverage Accuracy + in Nonparametric Inference}, + volume = {113}, + year = {2018}, +} + +@article{rbc, + author = {Calonico, Sebastian and Matias D. Cattaneo and + Max H. Farrell}, + journal = {Bernoulli}, + number = {4}, + pages = {2998--3022}, + title = {Coverage Error Optimal Confidence Intervals for Local + Polynomial Regression}, + volume = {28}, + year = {2022}, +} + +@article{lpdensitypaper, + title={Simple local polynomial density estimators}, + author={Cattaneo, Matias D and Jansson, Michael and Ma, Xinwei}, + journal={J. Amer. Statist. Assoc.}, + volume={115}, number={531}, pages={1449--1455}, year={2020} +} + + diff --git a/R/lpcde/man/lpbwcde.Rd b/R/lpcde/man/lpbwcde.Rd index a1c6f94..e4bbc82 100644 --- a/R/lpcde/man/lpbwcde.Rd +++ b/R/lpcde/man/lpbwcde.Rd @@ -64,7 +64,7 @@ bandwidth selected for each grid point)} \description{ \code{\link{lpbwcde}} implements the bandwidth selection methods for local polynomial based conditionaldensity (and derivatives) estimation proposed and studied -in Cattaneo, Chandak, Jansson and Ma (2021). +in \insertCite{bernoulli}{lpcde}. Companion command: \code{\link{lpcde}} for estimation and robust bias-corrected inference. @@ -85,6 +85,9 @@ summary(bw1) # Display bandwidths for a subset of y_grid points summary(bw1, y_grid=bw1$BW[2:5, "y_grid"]) +} +\references{ +\insertRef{bernoulli}{lpcde} } \author{ Matias D. Cattaneo, Princeton University. \email{cattaneo@princeton.edu}. diff --git a/R/lpcde/man/lpcde.Rd b/R/lpcde/man/lpcde.Rd index 190cbd6..7fd57f7 100644 --- a/R/lpcde/man/lpcde.Rd +++ b/R/lpcde/man/lpcde.Rd @@ -90,7 +90,7 @@ bandwidth selected for each grid point)} \description{ \code{\link{lpcde}} implements the local polynomial regression based conditional density (and derivatives). The estimator proposed in -Chandak, Cattaneo, Jansson and Ma. +\insertCite{bernoulli}{lpcde}. Robust bias-corrected inference methods, both pointwise (confidence intervals) and uniform (confidence bands), are also implemented. } @@ -117,6 +117,12 @@ of the confidence intervals/bands, which can happen if the underlying distributi high curvature at some evaluation point(s). One possible solution in this case is to increase the polynomial order \code{p} or to employ a smaller bandwidth. } +\references{ +\insertRef{bernoulli}{lpcde}\cr +\insertRef{JASA}{lpcde}\cr +\insertRef{rbc}{lpcde}\cr +\insertRef{lpdensitypaper}{lpcde} +} \author{ Matias D. Cattaneo, Princeton University. \email{cattaneo@princeton.edu}. diff --git a/R/lpcde_0.1.2.pdf b/R/lpcde_0.1.2.pdf index 2536393..824706c 100644 Binary files a/R/lpcde_0.1.2.pdf and b/R/lpcde_0.1.2.pdf differ