locally weighted least square regresion

6 visualizzazioni (ultimi 30 giorni)
Fahime Sokhangou
Fahime Sokhangou il 3 Ago 2022
Dear all
I have a curve that I would like to apply locally weighted polynominal regresion on them. I do not how how define the span and the weight for this type of regresion.
Thanks for your help in advance

Risposte (1)

KSSV
KSSV il 3 Ago 2022
t = linspace(0,2*pi) ;
y = sin(t) ;
p = polyfit(t,y,3) ;
xi = linspace(t(1),t(end)) ;
yi = polyval(p,xi) ;
plot(t,y,'r',xi,yi,'.b')
  3 Commenti
KSSV
KSSV il 3 Ago 2022
Least square regression:
A*x = b ; % A is m*n matrix, b is column matrix m*1
x = A\b ; % solve for unknow x
Weighted least square regression:
W = diag(W); % where W is column matrix of weights
x = (W*A)\(w.*y);
Fahime Sokhangou
Fahime Sokhangou il 3 Ago 2022
Modificato: Fahime Sokhangou il 3 Ago 2022
@KSSV thank you so much. so you mean that if I have curve with 68 points and I want to do local regresion smoothing with polynominal for this curve, I should define the weight myself and put them in the matrix. But in the paper that I am following, it is written 10 persent of data points and I do not know how to consider this span?
I do not know how to define the span...
also they used following weight function.
should I have (10%*68 points=7 weights) for each point?
I found the following link very helpful.
https://www.mathworks.com/matlabcentral/fileexchange/55407-loess-regression-smoothing?s_tid=srchtitle
Thanks in advance

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by