Learn R Programming

bda (version 3.2.0-3)

bde: Density Estimation for Binned Data

Description

Returns x and y coordinates of the density estimate of the probability density based on binned data.

Usage

bde(x, breaks,freq,bw,type="weibull",from,to,gridsize=512L,conf.level)

Arguments

x
A vector of sample data. 'NA' values will be automatically removed.
freq
vector of frequencies (counts) of different bins. Missing values are not allowed.
breaks
vector of breaking points.
bw
Bin (class) width.
from,to,gridsize
parameters to define fine equally spaced grid points at which to estimate the density.
type
Distribution family or smoothing type used to fit the histogram.
conf.level
Confidence level for the pointwise/simultaneous confidence bands.

Value

  • a list containing the following components:
  • x,yvector of sorted x values at which the density estimate y was computed.
  • mean,medianestimates of the mean and median based on the smooth estimates.
  • sigmaan estimate of the standard deviation.
  • type, parsIf parametric method is used, return the type of distribution family in type, and estimated parameters in pars.
  • ucb, lcb, conf.levelconf.level gives the confidence level; lcb and ucb are the corresponding confidence bands for the density function.

encoding

UTF-8

Details

Missing values are not allowed. A specific family of distribution is fitted to the a set of non-negative data that have binned. Families of distributions supported include:

code{ewd}: exponentiated Weibull distribution;

weibull{Weibull distribution;} dagum{Type I Dagum distribution.}

Some histogram-based smoothing methods include:

smkde,smoothkde{Blower and Kelsall's smooth KDE.} histospline{Minnottee (1996,1998)'s histospline estimate.} bootkde{Two-stage bootstrap KDE.}

npr/lpr/root-unroot{Estimate the density via local polynomial regression using root-unroot.} fnmm/nmix/normmix/nm{Fitting finite normal mixture model using EM algorithm.}

References

Wang, B. (2014). JSS paper.

Blower G, Kelsall J (2002). "Nonlinear kernel density estimation for binned data: convergence in entropy." Bernoulli, 8(4), 423-449.

Minnottee MC (1996). "The bias-optimized frequency polygon." Comput. Statist., 11, 35-48.

Minnottee MC (1998). "Achieving higher-order convergence rates for density estimation with binned data." JASA, 93(442), 663-672.

Wang, B. and Wertelecki, W. (2012) Density Estimation for Data With Rounding Errors. Computational Statistics and Data Analysis, doi: 10.1016/j.csda.2012.02.016.

Examples

Run this code
## parametric method
  data(hhi)
  cbind(hhi$mean, hhi$median)
  (out1 <- bde(freq=hhi$mob,breaks=hhi$breaks, type='weibull'))
## bootKDE
  (out1 <- bde(freq=hhi$mob,breaks=hhi$breaks, type='bootkde'))
  plot(out1, type='l')

## smooth KDE
  mu <- 34.5; s <- 1.5; n <- 1000
  y <- rnorm(n,mu,s) #raw data
  x <- round(y) #rounded data
  xhist <- binning(x, breaks=min(x)-0.5, bw=1)
  out <- bde(xhist,type='smkde')
  plot(out, type="l")
## histospline
  out <- bde(xhist,type='histospline')
  plot(out, type="l")
## nprde
  out <- bde(xhist,type='lpr')
  lines(out, col=2,lwd=2)

Run the code above in your browser using DataLab