Code covered by the BSD License  

Highlights from
Kernel Smoothing Regression

4.66667

4.7 | 12 ratings Rate this file 100 Downloads (last 30 days) File Size: 2.16 KB File ID: #19195
image thumbnail

Kernel Smoothing Regression

by Yi Cao

 

13 Mar 2008 (Updated 24 Dec 2008)

A non-parametrical regression (smoothing) tool using Gaussian kernel.

| Watch this File

File Information
Description

Non-parametric regression is widely used in many scientific and engineering areas, such as image processing and pattern recognition.

Non-parametric regression is about to estimate the conditional expectation of a random variable:

E(Y|X) = f(X)

where f is a non-parametric function.

Based on the kernel density estimation technique, this code implements the so called Nadaraya-Watson kernel regression algorithm particularly using the Gaussian kernel. The default bandwidth of the regression is derived from the optimal bendwidth of the Gaussian kernel density estimation suggested in the literature. The code can also take care of missing data.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Update PDF Estimation
This submission has inspired the following:
Multivariant Kernel Regression and Smoothing, Local Linear Kernel Regression, Volatility Surface, Kernel Regression with Variable Window Width

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (16)
13 Mar 2008 Dimitri Shvorob

Nice work! There are some typos that can be corrected; with more time on their hands, one could add clarification/input check 'x must be a vector', allow an arbitrary set of evaluation points x, make chosen default bandwidth selection procedure more prominent (I have to say I didn't know this one; have you consulted Pagan's little book?), or allow an arbitrary kernel via a function-handle input argument. Do you want to try coding local polynomial (vs. local linear) kernel regression? :)

13 Mar 2008 Dimitri Shvorob

Oops, I meant 'local polynomial (e.g. local linear) vs. local constant'. Does that make sense? Someone needs to refresh his stats :)

13 Mar 2008 Yi Cao

Dimitri,

Thanks for your suggestions. The file has been updated to take some of your points: typos have been corrected (I hope I found all of them. BTW, I wish the MATLAB editor has a spelling check functionality. -:) ) and valid inputs have been properly checked.

In terms of better bandwidth, I do not aware any simple one available for such problem. Most I knew either too complcated or requires significant computation, such as the one through cross validation. If anyone know this, please leave a message here.

Option for user provided function handle is not implemented. Mainly, I am concerned the difficulty to check the correctness of the function specified (i.e. positiveness and integrating to 1).

Finally, local polynomial regression will require more work. It will be considered in a future version.

17 Nov 2008 Abel Brown

this function rocks!! worked very well 'right outta the box'. My only question: Is is possible to do a variable bandwidth smoothing using this function?

At any rate, nice work
Thanks!

19 Dec 2008 J. Melon

Hi Yi, wouldn't this function produce all NaN if the median of either X or Y is zero? (since h would be zero)

Is there anyway to fix it? for example, if sigma is zero, then let sigma = max(X) - min(X)

21 Dec 2008 Yi Cao

Thanks for the comment. However, the zero median either in X or in Y should not be consider because we deal with a regression problem here. The case mentioned just means that X or Y are constant, then the regrassion problem is not well-posed and the solution is meaningless anyway.

17 Mar 2009 Gholamreza (Shahab) Anbarjafari

Hi, nice work :)

25 Mar 2009 Xu Wings  
25 Mar 2009 John D'Errico  
25 Mar 2009 Kenneth Eaton  
31 Mar 2009 Michael Jordan  
05 Apr 2009 V. Poor  
27 Aug 2009 cf 

It works very well and friendly.

08 Jul 2011 ben salah

nice

18 Jul 2011 Charles  
15 Mar 2012 temp  
Please login to add a comment or rating.
Updates
13 Mar 2008

update with error checking.

24 Dec 2008

add an error case

Tag Activity for this File
Tag Applied By Date/Time
statistics Yi Cao 22 Oct 2008 09:53:22
probability Yi Cao 22 Oct 2008 09:53:22
kernel smoothing Yi Cao 22 Oct 2008 09:53:22
kernel regression Yi Cao 22 Oct 2008 09:53:22
nonparametric regression Yi Cao 22 Oct 2008 09:53:22
kernel regression Alexander Migita 17 Dec 2009 05:39:45
kernel smoothing qwerty 06 Jun 2011 13:21:53
kernel regression Zheng 07 Apr 2012 21:08:20
kernel smoothing Zheng 07 Apr 2012 21:21:28
statistics Zheng 07 Apr 2012 21:21:40
nonparametric regression Francesc Iu Rillo Moral 10 May 2012 11:36:46

Contact us at files@mathworks.com