Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: smoother
See also: denest denci dencb denrot denbwsel denestp

Quantlet: denxest
Description: estimates a univariate density by kernel density estimation.

Usage: fh = denxest(x {,h {,K} {,v} })
Input:
x n x 1 vector, the data.
h scalar, bandwidth. If not given, the rule of thumb bandwidth computed by denrot is used (Silverman's rule of thumb).
K string, kernel function on [-1,1] or Gaussian kernel "gau". If not given, the Quartic kernel "qua" is used.
v m x 1, values of the independent variable on which to compute the density estimate. If not given, x is used.
Output:
fh n x 2 or m x 2 matrix, the first column is the sorted first column of x or the sorted v, the second column contains the density estimate on on the values of the first column.

Note:

Example:

library("smoother")                                       

library("plot")

;

mu = 10

si = 5

x  = si*normal(200)+mu          ; generate data

;                                  

fh = denxest(x)                  ; estimate density

f  = sort(x~pdfn((x-mu)/si)/si) ; true density                   ;             ;                                  

fh = setmask(fh,"line","blue")

f  = setmask(f ,"line","black","thin")

plot(f,fh)                      ; graph functions

Result:

The density estimate (blue) for a normal distribution 

with mean mu=10, standard deviation si=5 is pictured 

using Quartic kernel (default) and Silverman's 

rule-of-thumb bandwidth (default), together with 

the true density (thin black).

Example:

library("smoother")                                       

library("plot")

;

mu = 10

si = 5

x  = si*normal(200)+mu           ; generate data   

;                                  

fhe= denxest(x,3,"epa")           ; estimate density

fhu= denxest(x,3,"uni")           ; estimate density

f  = sort(x~pdfn((x-mu)/si)/si)  ; true density    

;                              

fhe= setmask(fhe,"line","green")

fhu= setmask(fhu,"line","red")

f  = setmask(f ,"line","black","thin")

plot(f,fhu,fhe)                  ; graph functions

Result:

The density estimate using the Epanechnikov kernel 

(green) is compared to the density estimate using

the Uniform kernel (red) and the true density (thin 

black). In both cases, bandwidth h=3 is used.


Library: smoother
See also: denest denci dencb denrot denbwsel denestp

Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Author: Marlene Mueller, 990413
(C) MD*TECH Method and Data Technologies, 21.9.2000