I have the following data:
x = [15, 25, 35, 45, 55, 65, 75]
y = [22.3, 27.5, 28.8, 29.9, 29.6, 27.4, 23.3]
How could I create a good regression that would fit the data above best. I'm trying to plot them both on the same graph so you can see the different between both lines.

4 comentarios

Adam Danz
Adam Danz el 30 de Abr. de 2020
Do you know the underlying function or do you have an expectation of what the function should be?
Alex Sha
Alex Sha el 1 de Mayo de 2020
The fitting model below is good enough:
y = p1+p2*x+p3*ln(x)+p4/x+p5/x^2
Root of Mean Square Error (RMSE): 0.00486074972111081
Sum of Squared Residual: 0.000165388214958952
Correlation Coef. (R): 0.999998485296235
R-Square: 0.999996970594765
Parameter Best Estimate
---------- -------------
p1 -1030.61369989144
p2 -2.88996744088543
p3 271.393077102476
p4 7919.34753749812
p5 -37493.8788669532
Ameer Hamza
Ameer Hamza el 1 de Mayo de 2020
Is this result also from 1stOpt? Did you specify the equation or the toolbox is also able to find a suitable equation to fit the data points automatically? I have never tried it, so I am not aware of all the features.
Alex Sha
Alex Sha el 1 de Mayo de 2020
There is also a function in 1stOpt in which the best fit model function could be serached automatically according to the data user provided.

Iniciar sesión para comentar.

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 30 de Abr. de 2020
Editada: Ameer Hamza el 30 de Abr. de 2020

1 voto

One option is to use smoothingspline option from the curve fitting toolbox
x = [15, 25, 35, 45, 55, 65, 75];
y = [22.3, 27.5, 28.8, 29.9, 29.6, 27.4, 23.3];
model = fit(x(:), y(:), 'smoothingspline');
plot(x, y, 'r+');
hold on
xv = linspace(min(x), max(x));
plot(xv, model(xv), 'b-');

2 comentarios

Jessica Larry
Jessica Larry el 30 de Abr. de 2020
Editada: Jessica Larry el 30 de Abr. de 2020
I was able to resolve it, thank you so much for the help!!
Ameer Hamza
Ameer Hamza el 30 de Abr. de 2020
Glad to be of help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Linear and Nonlinear Regression en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 30 de Abr. de 2020

Comentada:

el 1 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by