Error in linear regression with predefined error in y
Show older comments
I'm fitting y=ax+b with polyfit. x has no errors, but every component y_i has an error equal to error_i = C_i*y_i. (So this is correlated right?) How do I determine the error in the slope a?
I've been thinking about not using polyfit and minimazing S = sum(w_i * ( y_i - fit_i)^2) myself. With w_i = 1/error_i^2. But I have no idea how this minimizing can be done.
Accepted Answer
More Answers (1)
Wayne King
on 23 May 2012
0 votes
polyfit returns a least-squares fit, but not with weights as you suggest. Do you have the Statistics Toolbox? If so consider, robustfit.m or LinearModel.fit, which has options for robust fitting.
Also, perhaps a simple first-order linear model is not adequate for your data?
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!