Learn R Programming

bda (version 1.2.7-31)

histolpr: Fit smoothed KDE to binned data.

Description

Fit smoothed KDE to binned data via an iterative algorithm.

Usage

histolpr(x, weights, bandwidth,
	gridsize=512L,range.x,
        binned = FALSE, truncate = TRUE)

Arguments

x
vector of raw data or distinct center information of binned data.
weights
The weights of x. The weight w_i of any observation x_i should be non-negative. If x_i=0, x_i will be removed from the analysis.
bandwidth
the kernel bandwidth smoothing parameter. Larger values of bandwidth make smoother estimates, smaller values of bandwidth make less smooth estimates.
gridsize
The size of grid where the density will be evaluated.
range.x
vector containing the minimum and maximum values of x at which to compute the estimate. The default is the minimum and maximum data values, extended by the support of the kernel.
truncate
logical flag: if TRUE, data with x values outside the range specified by range.x are ignored.
binned
Have the data been binned. Default: FALSE.

See Also

histo.

Examples

Run this code
p = c(.4,.6)
mu = c(34.5,40)
s=c(1.5,1.3)
x = rmixnorm(300,p,mu,s)
x0 = seq(min(x),max(x),length=100)
plot(dmixnorm(x0,p,mu,s)~x0,type='l')
lines(density(x), col=3,lty=3)
out = histolpr(x)
lines(out,col=2,lty=2)

Run the code above in your browser using DataLab