Learn R Programming

circglmbayes (version 1.3.0)

estimateDensityBySpline: Estimate the density value from a sample by a spline interpolation of the kernel density

Description

This function estimates the density at x0 by first taking a kernel density estimate of a sample from the probability density x, and then interpolating it by a spline.

Usage

estimateDensityBySpline(x, x0 = 0, npow = 15, rangeExtend = 1/4)

Arguments

x

A (large) sample of from the probability density function of interest, such as a posterior.

x0

The value at which to evaluate the density.

npow

The precision used with the density function.

rangeExtend

The number of standard deviations past the range of x to start the density estimate.

Value

Numeric; a scalar of the estimated probability density at x0.

Examples

Run this code
# NOT RUN {
# Compare the estimate from this function with the analytic result.
estimateDensityBySpline(rnorm(1000), 0.1)
dnorm(.1)

# }

Run the code above in your browser using DataLab