Thread Subject: weighted least squares beginner

Subject: weighted least squares beginner

From: leo nidas

Date: 20 Aug, 2008 19:02:02

Message: 1 of 1


Hi there,

I am reading the tutorial and trying to understand the
concept of weighted least squares.

I am a little confused about the form of the data one
should have. For each x, we should have multiple responses
so as to see if we have heteroscedacity, and then calculate
the variances of Y for each Xi? If I have data like the
following example (one y for one x) how can I calculate the
variance in order to use the formula for the weights
(w=1/σ^2) since the variance of a single number is 0?
Weighted Least Squares is not an appropriate method to data
like this? I have arbitrarily set weight 0.2 to the outlier.

x = (1:10)';
y = 10 - 2*x + randn(10,1);
y(10) = 0;
bls=regress(y,[ones(1,length(x))' x])

w=[1 1 1 1 1 1 1 1 1 0.2]';
[bw,sew_b,msew] = lscov([ones(1,length(x))' x],y,w)

brob = robustfit(x,y)


scatter(x,y,'filled'); grid on; hold on
plot(x,bls(1)+bls(2)*x,'r','LineWidth',2);
plot(x,bw(1)+bw(2)*x,'g','LineWidth',2)
plot(x,brob(1)+brob(2)*x,'k','LineWidth',2)
legend('Data','Ordinary Least Squares','Weighted
Fit','Robust Regression')

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
weighted least ... leo nidas 20 Aug, 2008 15:05:05
rssFeed for this Thread

Contact us at files@mathworks.com