Modifies stats::density by:
Adding SE and 95% confidence intervals for the density to the output; and
Truncating calculation (not just reporting) of density values on from and/or to.
Usage
density2(x, reps = 999, ...)
Arguments
x
numeric data vector
reps
bootstrap iterations for SE/interval calculation; set to NULL to suppress
...
Additional arguments passed to stas::density
Value
A list with the same components as stats::density output plus:
se: standard error of the density
lcl, ucl: lower and upper 95% confidence intervals of the density
Details
Truncation copes with cases where no data are available outside truncation points.
Truncation is achieved by fitting the density to the data augmented by reflecting it
across each bound using the optimal bandwidth for the unaugmented data, and returning
the resulting densities for the region between the bounds.