Linear Regression - more weight on specific Bins of data
4 次查看(过去 30 天)
显示 更早的评论
Hi, I am sort of new to Matlab and I need to analyze some data on Matlab. What I need to do is; I have a scatter plot (x, y) and I need to do a linear regression on this data in a way that I have more weight on a specific section (or bins)of my x axis.For example, my x axis is from 0 to 45, and i want to make a linear regression of the data so that I have more weight on data between 15 to 40, and less weight on data points above 40. For this I have to BIN my data points to 5 parts, (1 bin < x<15, 2 bins when x between 15 and 40 , and 1 bin when x is higher than 40). How can I do this easily in Matlab. I used polyfit for the linear regression, but how can I modify it to do such a thing. Thanks alot.
0 个评论
回答(3 个)
Richard Willey
2011-11-28
MathWorks tech support has a solution documenting various options for weighted regression.
From my perspective, robustfit provides the most flexibility.
Daniel Shub
2011-11-28
I am not sure you can do it easily with polyfit. The cftool and lscov both allow differential weighting.
0 个评论
Michael
2011-11-28
lsqnonlin may be a good place to start, rather than giving it your model function and a starting point (eg. lsqcurvefit), you give it a function which returns a vector of the residuals of the fit. This way you have the freedom to multiply these residuals by factors based on their corresponding x coordinate- if a residual is multiplied by two, the minimisation scheme in lsqnonlin should work harder to ensure that this point is close to the final curve.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!