Home > wafo > kdetools > hboot.m

hboot

PURPOSE ^

Bootstrap cross-validation estimate of smoothing parameter.

SYNOPSIS ^

[h,hvec,score]=hboot(A,kernel,hvec)

DESCRIPTION ^

 HBOOT  Bootstrap cross-validation estimate of smoothing parameter. 
  
  CALL: [hs,hvec,score] = hboot(data,kernel,hvec);  
   
    hs     = smoothing parameter 
    hvec   = vector defining possible values of hs 
             (default linspace(0.25*h0,h0,100), h0=hos(data,kernel)) 
    score  = score vector 
    data   = data vector 
    kernel = 'epanechnikov'  - Epanechnikov kernel.  
             'biweight'      - Bi-weight kernel. 
             'triweight'     - Tri-weight kernel.   
             'triangluar'    - Triangular kernel. 
             'gaussian'      - Gaussian kernel 
             'rectangular'   - Rectanguler kernel.  
             'laplace'       - Laplace kernel. 
             'logistic'      - Logistic kernel. 
  
   Note that only the first 4 letters of the kernel name is needed. 
    
   Example: data = wnormrnd(0, 1,20,1) 
           [hs hvec score] = hboot(data,'epan'); 
           plot(hvec,score)  
  See also  hste, hbcv, hos, hldpi, hlscv, hscv, hstt, kde, kdefun

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [h,hvec,score]=hboot(A,kernel,hvec) 
002 %HBOOT  Bootstrap cross-validation estimate of smoothing parameter. 
003 % 
004 % CALL: [hs,hvec,score] = hboot(data,kernel,hvec);  
005 %  
006 %   hs     = smoothing parameter 
007 %   hvec   = vector defining possible values of hs 
008 %            (default linspace(0.25*h0,h0,100), h0=hos(data,kernel)) 
009 %   score  = score vector 
010 %   data   = data vector 
011 %   kernel = 'epanechnikov'  - Epanechnikov kernel.  
012 %            'biweight'      - Bi-weight kernel. 
013 %            'triweight'     - Tri-weight kernel.   
014 %            'triangluar'    - Triangular kernel. 
015 %            'gaussian'      - Gaussian kernel 
016 %            'rectangular'   - Rectanguler kernel.  
017 %            'laplace'       - Laplace kernel. 
018 %            'logistic'      - Logistic kernel. 
019 % 
020 %  Note that only the first 4 letters of the kernel name is needed. 
021 %   
022 %  Example: data = wnormrnd(0, 1,20,1) 
023 %          [hs hvec score] = hboot(data,'epan'); 
024 %          plot(hvec,score)  
025 % See also  hste, hbcv, hos, hldpi, hlscv, hscv, hstt, kde, kdefun  
026  
027 % tested on : matlab 5.2 
028 % history: 
029 % revised pab dec2003 
030 %  -fixed a bug in default value for hvec   
031 % revised pab 20.10.1999 
032 %   updated to matlab 5.2 
033 % changed input arguments 
034 % taken from kdetools     Christian C. Beardah 1995  
035  
036 A=A(:); 
037 n=length(A); 
038  
039 if nargin<3|isempty(hvec), 
040   H    = hos(A,kernel); 
041   hvec = linspace(0.25*H,H,100); 
042 else 
043   hvec=abs(hvec); 
044 end; 
045    
046 steps=length(hvec); 
047  
048  
049 M=A*ones(size(A')); 
050  
051 Y1=(M-M'); 
052   
053 [mu2,R] = kernelstats(kernel); 
054 STEconstant =  R /(mu2^(2)*n); 
055  
056 kernel2 = 'gauss'; 
057 [mu2,R] = kernelstats(kernel2); 
058 STEconstant2 =  R /(mu2^(2)*n); 
059  
060 hvec = hvec*(STEconstant2/STEconstant)^(1/5); 
061  
062  
063 for i=1:steps, 
064  
065   Y=-Y1.^2/(4*hvec(i)^2); 
066  
067   T1=exp(Y/2); 
068  
069   T1=T1-diag(diag(T1)); 
070  
071   T2=-4*exp(Y/1.5)/sqrt(3); 
072  
073   T2=T2-diag(diag(T2)); 
074  
075   T3=sqrt(2)*exp(Y); 
076  
077   T3=T3-diag(diag(T3)); 
078  
079   T=T1+T2+T3; 
080  
081   T=sum(sum(T))+n*sqrt(2); 
082  
083   score(i)=T/(2*n^2*hvec(i)*sqrt(2*pi)); 
084  
085 end; 
086  
087 [L,I]=min(score); 
088  
089 hvec = hvec*(STEconstant/STEconstant2)^(1/5); 
090  
091  
092 h=hvec(I); 
093

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