Weighted Least Squares, Need Help!!

3 views (last 30 days)
SB
SB on 26 Oct 2012
A question asks to determine write a function to solve the weighted least squares problem, without using advanced functions (limited to mldivide, for loops,etc). I know a weighted least squares problem can be solved by the basic least squares method after multiplying both Yi and the ith row of X by wi, but I'm not sure how to write any of the code in this case.

Answers (1)

Tom Lane
Tom Lane on 27 Oct 2012
Well, y.*w multiplies each element of y by the corresponding element of w. To do this with a matrix x having multiple columns, try "help repmat" or "help bsxfun". Also consider whether you need to use sqrt(w) or w -- it depends on how you define your weights.

Categories

Find more on Descriptive Statistics 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!