density2 {activity} | R Documentation |
Modified kernel density function
Description
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 |
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.
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
Examples
data(BCItime)
tm <- subset(BCItime, species=="ocelot")$time
dens <- density2(tm, from=0.25, to=0.75)
plot(dens$x, dens$y, type="l")