Home > wafo > kdetools > hmns.m

hmns

PURPOSE ^

Multivariate Normal Scale Estimate of Smoothing Parameter.

SYNOPSIS ^

h=hmns(A,kernel)

DESCRIPTION ^

 HMNS Multivariate Normal Scale Estimate of Smoothing Parameter. 
  
  CALL:  h = hmns(data,kernel) 
  
    h      = M dimensional optimal value for smoothing parameter 
             given the data and kernel.  size D x D 
    data   = data matrix, size N x D (D = # dimensions ) 
    kernel = 'epanechnikov'  - Epanechnikov kernel. 
             'biweight'      - Bi-weight kernel. 
             'triweight'     - Tri-weight kernel.   
             'gaussian'      - Gaussian kernel 
    
   Note that only the first 4 letters of the kernel name is needed. 
   
  HMNS  only gives  a optimal value with respect to mean integrated  
  square error, when the true underlying distribution  is 
  Multivariate Gaussian. This works reasonably well if the data resembles a 
  Multivariate Gaussian distribution. However if the distribution is  
  asymmetric, multimodal or have long tails then HNS is maybe more  
  appropriate. 
  
   Example: data = wnormrnd(0, 1,20,2) 
            h = hmns(data,'epan'); 
    
  See also  hns, hste, hbcv, hboot, hos, hldpi, hlscv, hscv, hstt

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function h=hmns(A,kernel) 
002 %HMNS Multivariate Normal Scale Estimate of Smoothing Parameter. 
003 % 
004 % CALL:  h = hmns(data,kernel) 
005 % 
006 %   h      = M dimensional optimal value for smoothing parameter 
007 %            given the data and kernel.  size D x D 
008 %   data   = data matrix, size N x D (D = # dimensions ) 
009 %   kernel = 'epanechnikov'  - Epanechnikov kernel. 
010 %            'biweight'      - Bi-weight kernel. 
011 %            'triweight'     - Tri-weight kernel.   
012 %            'gaussian'      - Gaussian kernel 
013 %   
014 %  Note that only the first 4 letters of the kernel name is needed. 
015 %  
016 % HMNS  only gives  a optimal value with respect to mean integrated  
017 % square error, when the true underlying distribution  is 
018 % Multivariate Gaussian. This works reasonably well if the data resembles a 
019 % Multivariate Gaussian distribution. However if the distribution is  
020 % asymmetric, multimodal or have long tails then HNS is maybe more  
021 % appropriate. 
022 % 
023 %  Example: data = wnormrnd(0, 1,20,2) 
024 %           h = hmns(data,'epan'); 
025 %   
026 % See also  hns, hste, hbcv, hboot, hos, hldpi, hlscv, hscv, hstt 
027  
028 % Reference:   
029 %  B. W. Silverman (1986)  
030 % 'Density estimation for statistics and data analysis'   
031 %  Chapman and Hall, pp 43-48, 87  
032 % 
033 %  Wand,M.P. and Jones, M.C. (1995)  
034 % 'Kernel smoothing' 
035 %  Chapman and Hall, pp 60--63, 86--88 
036  
037  
038 %Tested on: matlab 5.3 
039 % History: 
040 % revised pab dec2003   
041 % by pab 06.12.99 
042 %  
043  
044 % TODO % implement more kernels   
045    
046  
047 [n d]=size(A); 
048 if (n==1) & (d>1), 
049   A=A'; 
050   n=d; 
051   d=1; 
052 end 
053 if d==1, 
054   h=hns(A,kernel); 
055   return 
056 end 
057  
058 switch lower(kernel(1:4)) 
059 case {'epan' }, % Epanechnikov kernel 
060  a=(8*(d+4)*(2*sqrt(pi))^d/vsph(d))^(1/(4+d)); 
061 case 'biwe', % Bi-weight kernel 
062   a=2.7779; 
063   if d>2 
064    error('not implemented for d>2') 
065   end  
066 case 'triw', % Triweight 
067   a=3.12; 
068   if d>2 
069     error('not implemented for d>2') 
070   end  
071 case 'gaus', % Gaussian kernel 
072  a=(4/(d+2))^(1/(d+4)); 
073  
074  otherwise 
075   error('Unknown kernel.') 
076 end; 
077 covA = cov(A); 
078  
079 h=a*sqrtm(covA)*n^(-1/(d+4)); 
080  
081 return 
082  
083

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003