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

2 vues (au cours des 30 derniers jours)
J le 5 Avr 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.
##### 0 commentairesAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (1)

Richard Willey le 5 Avr 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))
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.
##### 0 commentairesAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!