Least squares linear regression when squares have to do with elasticity?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Richard Willey
el 5 de Abr. de 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.
0 comentarios
Ver también
Categorías
Más información sobre Linear Regression en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!