Density estimation

Density estimation

In probability and statistics, density estimation is the construction of an estimate, based on observed data, of an unobservable underlying probability density function. The unobservable density function is thought of as the density according to which a large population is distributed; the data are usually thought of as a random sample from that population.

A variety of approaches to density estimation are used, including Parzen windows and a range of data clustering techniques, including vector quantization. The most basic form of density estimation is a rescaled histogram.


Example of density estimation

We will consider records of the incidence of diabetes. The following is quoted verbatim from the data set description:

A population of women who were at least 21 years old, of Pima Indian heritage and living near Phoenix, Arizona, was tested for diabetes according to World Health Organization criteria. The data were collected by the US National Institute of Diabetes and Digestive and Kidney Diseases. We used the 532 complete records.

In this example, we construct three density estimates for "glu" (plasma glucose concentration), one conditional on the presence of diabetes, the second conditional on the absence of diabetes, and the third not conditional on diabetes. The conditional density estimates are then used to construct the probability of diabetes conditional on "glu".

The "glu" data were obtained from the MASS package of the R programming language. Within 'R', ? and ?Pima.te give a fuller account of the data.

The mean of "glu" in the diabetes cases is 143.1 and the standard deviation is 31.26. The mean of "glu" in the non-diabetes cases is 110.0 and the standard deviation is 24.29. From this we see that, in this data set, diabetes cases are associated with greater levels of "glu". This will be made clearer by plots of the estimated density functions.

The first figure shows density estimates of p(glu | diabetes=1), p(glu | diabetes=0), and p(glu). The density estimates are kernel density estimates using a Gaussian kernel. That is, a Gaussian density function is placed at each data point, and the sum of the density functions is computed over the range of the data.

P glu given diabetes.png
Estimated density of p(glu | diabetes=1) (red), p(glu | diabetes=0) (blue), and p(glu) (black).

From the density of "glu" conditional on diabetes, we can obtain the probability of diabetes conditional on "glu" via Bayes' rule. For brevity, "diabetes" is abbreviated "db." in this formula.

 = \frac{p(\mbox{glu}|\mbox{db.}=1)\,p(\mbox{db.}=1)}{p(\mbox{glu}|\mbox{db.}=1)\,p(\mbox{db.}=1) + p(\mbox{glu}|\mbox{db.}=0)\,p(\mbox{db.}=0)}

The second figure shows the estimated posterior probability p(diabetes=1 | glu). From these data, it appears that an increased level of "glu" is associated with diabetes.

P diabetes given glu.png
Estimated probability of p(diabetes=1 | glu).

Script for example

The following commands of the R programming language will create the figures shown above. These commands can be entered at the command prompt by using cut and paste.

library (MASS)


Pima <- rbind (, Pima.te)
glu <- Pima[,'glu']

d0 <- Pima[,'type'] == 'No'
d1 <- Pima[,'type'] == 'Yes'
base.rate.d1 <- sum(d1)/(sum(d1) + sum(d0))

glu.density <- density (glu)
glu.d0.density <- density (glu[d0])
glu.d1.density <- density (glu[d1])

approxfun (glu.d0.density$x, glu.d0.density$y) -> glu.d0.f
approxfun (glu.d1.density$x, glu.d1.density$y) -> glu.d1.f

p.d.given.glu <- function (glu, base.rate.d1)
   p1 <- glu.d1.f(glu) * base.rate.d1
   p0 <- glu.d0.f(glu) * (1 - base.rate.d1)

x <- 1:250
y <- p.d.given.glu (x, base.rate.d1)
plot (x, y, type='l', col='red', xlab='glu', ylab='estimated p(diabetes|glu)')

plot (density(glu[d0]), col='blue', xlab='glu', ylab='estimate p(glu), 
   p(glu|diabetes), p(glu|not diabetes)', main=NA)
lines (density(glu[d1]), col='red')

Note that the above conditional density estimator uses bandwidths that are optimal for unconditional densities. Alternatively, one could use the method of Hall, Racine and Li (2004) and the R np package for automatic (data-driven) bandwidth selection that is optimal for conditional density estimates; see the np vignette for an introduction to the np package. The following commands of the R programming language use the npcdens() function to deliver optimal smoothing. Note that the response "Yes"/"No" is a factor.


fy.x <- npcdens(type~glu,nmulti=1,data=Pima)

Pima.eval <- data.frame(type=factor("Yes"),

plot (x, y, type='l', lty=2, col='red', xlab='glu',
     ylab='estimated p(diabetes|glu)')


legend(0,1,c("Unconditional bandwidth", "Conditional bandwidth"),

The third figure uses optimal smoothing via the method of Hall, Racine, and Li (2004) indicating that the unconditional density bandwidth used in the second figure above yields a conditional density estimate that may be somewhat undersmoothed.

Glu opt.png
Estimated probability of p(diabetes=1 | glu).

See also


  • Peter Hall, Jeffrey S. Racine and Qi Li. "Cross-Validation and the Estimation of Conditional Probability Densities". Journal of The American Statistical Association, Volume 99, Number 468, pp 1015-1026, 2004.
  • Brian D. Ripley. Pattern Recognition and Neural Networks. Cambridge: Cambridge University Press, 1996.
  • Trevor Hastie, Robert Tibshirani, and Jerome Friedman. The Elements of Statistical Learning. New York: Springer, 2001. ISBN 0-387-95284-5. (See Chapter 6.)
  • Qi Li and Jeffrey S. Racine. Nonparametric Econometrics: Theory and Practice. Princeton University Press, 2007, ISBN 0691121613. (See Chapter 1.)
  • D.W. Scott. Multivariate Density Estimation. Theory, Practice and Visualization. New York: Wiley, 1992.
  • B.W. Silverman. Density Estimation. London: Chapman and Hall, 1986. ISBN 9780412246203
  • J.W. Smith, J.E. Everhart, W.C. Dickson, W.C. Knowler, and R.S. Johannes. "Using the ADAP learning algorithm to forecast the onset of diabetes mellitus". In Proceedings of the Symposium on Computer Applications in Medical Care (Washington, 1988), ed. R.A. Greenes, pp. 261-265. Los Alamitos, CA: IEEE Computer Society Press, 1988.

External links

Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Kernel density estimation — of 100 normally distributed random numbers using different smoothing bandwidths. In statistics, kernel density estimation is a non parametric way of estimating the probability density function of a random variable. Kernel density estimation is a… …   Wikipedia

  • Multivariate kernel density estimation — Kernel density estimation is a nonparametric technique for density estimation i.e., estimation of probability density functions, which is one of the fundamental questions in statistics. It can be viewed as a generalisation of histogram density… …   Wikipedia

  • Spectral density estimation — In statistical signal processing, the goal of spectral density estimation is to estimate the spectral density (also known as the power spectrum) of a random signal from a sequence of time samples of the signal. Intuitively speaking, the spectral… …   Wikipedia

  • Kernel density estimation — Die Kerndichteschätzung (auch Parzen Methode[1], englisch: Kernel Density Estimation, KDE) ist ein Verfahren zur Darstellung einer eindimensionalen Verteilung. In der klassischen Statistik geht man davon aus, dass statistische Phänomene einer… …   Deutsch Wikipedia

  • Estimation theory — is a branch of statistics and signal processing that deals with estimating the values of parameters based on measured/empirical data. The parameters describe an underlying physical setting in such a way that the value of the parameters affects… …   Wikipedia

  • Estimation par noyau — Estimation par la méthode du noyau d un échantillon de 100 nombres aléatoires distribués selon la loi normale pour différentes valeurs de la fenêtre. En statistique, l’estimation par noyau (ou encore méthode de Parzen Rozenblatt) est une méthode… …   Wikipédia en Français

  • Density (disambiguation) — Density and dense usually refer to a measure of how much of some entity is within a fixed amount of space. Types of density include: In physics, density of mass: Density, mass per volume Area density or surface density, mass over a (two… …   Wikipedia

  • Estimation of covariance matrices — In statistics, sometimes the covariance matrix of a multivariate random variable is not known but has to be estimated. Estimation of covariance matrices then deals with the question of how to approximate the actual covariance matrix on the basis… …   Wikipedia

  • Maximum spacing estimation — The maximum spacing method tries to find a distribution function such that the spacings, D(i), are all approximately of the same length. This is done by maximizing their geometric mean. In statistics, maximum spacing estimation (MSE or MSP), or… …   Wikipedia

  • Spectral density — In statistical signal processing and physics, the spectral density, power spectral density (PSD), or energy spectral density (ESD), is a positive real function of a frequency variable associated with a stationary stochastic process, or a… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”