Local Regression 2D
This function will perform a local regression at the given points. Using the data at hand. You will need to input a spanwidth which will tell the function how many datapoints he will use in the local regression at each evaluation.
Example Code
X=-5:0.05:10;
X=X';
y=2*X-X.^2;
y=y+normrnd(0,2,size(y));
scatter(X,y)
X0=X;
robust=1;
spanwidth=0.4
X0=[-5:0.1:10]';
[eps]=MLR(X,y,spanwidth,X0,robust)
Assumption for use local Regression
The underlying function between y and X is continues and has a 1st derivative at any point.
Explanation
X= 1 column vector with data points
y= 1 column vector with data points
spanwidth= number between 0 and 1
X0= column vector specifying the points that you want to be evaluated
robust= either 0 or 1
( if you choose 1 then robust version is used )
Plot explanation
-The straight blue line is the local regression approximation at a certain point
- The green points are used for local regression
- The Red points are left out
- The blue dot in middle of blue line is the current point .
Please leave a comment with your opinion
Cite As
Arnout Tilgenkamp (2024). Local Regression 2D (https://www.mathworks.com/matlabcentral/fileexchange/28551-local-regression-2d), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.