Least squares linear regression when squares have to do with elasticity?

1 Ansicht (letzte 30 Tage)
J
J am 5 Apr. 2012
How can I calculate a least squares linear regression when squares have to do with elasticity?
Say in an ordinary least squares regression, a square distance from one point to the regression line is ydelta^2. I want the same ydelta distance to more important for some points than for others depending on elasticity functions for each points.
Is it possible to create this type of regression using a matlab formula? I am not a mathematician by trade.

Antworten (1)

Richard Willey
Richard Willey am 5 Apr. 2012
Here's a simple example using the new regression functions in the 12a release. All you need to do is pass the appropriate weight vector in to the LinearModel function.
% Generate some data
X = 10 * rand(100,1);
Y = 5 + 3*X + randn(100,1);
% Assume a weight vector
temp = linspace(1, 50, 50);
temp = temp';
Weight_Vector = vertcat(temp, flipud(temp))
% Perform your regression
myFit = LinearModel.fit(X,Y, 'Weights', Weight_Vector)
plot(myFit)
FWIW, you can also pass weight vectors in to other regression functions, so if you're easier earlier versions of the Tbx you should be fine.

Kategorien

Mehr zu Descriptive Statistics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by