Non linear fitting with 3 independent variables

9 visualizaciones (últimos 30 días)
Shubham
Shubham el 8 de Mayo de 2024
Comentada: Alex Sha el 10 de Mayo de 2024
I have a dataset consisting of one dependent variable (K) and 3 independent variables (a, IL, Vf). I am trying to fit a function which could represent dependent variable with fair amount of accuracy.
I have attached the Data.mat file consisting of the dataset.
The form I am trying to fit is -
K = (A - B*IL - C*a)*(D*exp(-E*Vf))
LaTeX form:
initial guess could be - , , , ,
I want the optimised coefficients for the best fitting. How to do this in curve fitting app I was able to do 2 independent variables. I am not aware of how to do this.
Also if not this function how to find some other simple function/functional forms that could represent this data. In academic research lot of people find correlation like this.
load('Data.mat');
PS - Please don't suggest a polynomial type fit consisting of linear, square and interaction terms. As the aim is to have minimum coefficients ie simpler equation.
  2 comentarios
Torsten
Torsten el 8 de Mayo de 2024
The D in your fitting function makes the problem overfitted - D must be absorbed in A, B and C.
Shubham
Shubham el 8 de Mayo de 2024
D is redundant, anyway it will get multiplied. You can just remove that it was my mistake.

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 8 de Mayo de 2024
Editada: Matt J el 8 de Mayo de 2024
S=load('Data');
f=@(E,S)exp(-E.*S.Vf);
funlist={f, @(E,S) -S.IL.*f(E,S), @(E,S) -S.a.*f(E,S)};
[E,ABC]=fminspleas(funlist,2.65, S, S.K); %From File Exchange: https://www.mathworks.com/matlabcentral/fileexchange/10093-fminspleas
[A,B,C,E]=deal(ABC(1), ABC(2), ABC(3),E)
A = 225.3644
B = 1.7663
C = 0.0471
E = 2.8195
pred=(A - B*S.IL - C*S.a).*exp(-E.*S.Vf);
[pred,is]=sort(pred);
h=plot([S.K(is),pred]); legend 'K Measured' 'K Fit'
[h.Marker]=deal('x','o');
  2 comentarios
Shubham
Shubham el 8 de Mayo de 2024
Thanks a lot sir. One last question how to find good functions to fit this data. As the R2 value for this functional form is around 0.86 which is kind of poor. Aim is to get R2 value around 0.95.
Matt J
Matt J el 8 de Mayo de 2024
Editada: Matt J el 8 de Mayo de 2024
Improving the model is something only you are qualified to do.

Iniciar sesión para comentar.

Más respuestas (1)

Torsten
Torsten el 8 de Mayo de 2024
Editada: Torsten el 8 de Mayo de 2024
M = load("Data.mat");
fun = @(A,B,C,E)(A - B*M.IL - C*M.a).*exp(-E*M.Vf);
f = @(A,B,C,E) fun(A,B,C,E) - M.K;
A0 = 13.5*13.2;
B0 = 0.2*13.2;
C0 = 0.002*13.2;
E0 = 2.65;
z0 = [A0,B0,C0,E0];
sol = lsqnonlin(@(z)f(z(1),z(2),z(3),z(4)),z0)
Local minimum possible. lsqnonlin stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
sol = 1x4
225.3648 1.7663 0.0471 2.8195
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
A = sol(1);
B = sol(2);
C = sol(3);
E = sol(4);
n = numel(M.IL);
hold on
plot(1:n,M.K,'ob')
plot(1:n,fun(A,B,C,E),'r')
hold off
  7 comentarios
Sam Chak
Sam Chak el 8 de Mayo de 2024
Have you studied the amplitude of K and observed the patterns of IL, a, and Vf, before suggesting the use of an exponential decay function? The coefficients of the heaviside 'IL' and staircase 'a' have a lesser impact on K compared to the sawtooth-like wave 'Vf'.
The output signal K may or may not have the same frequency as the input signal Vf. It depends on the specific system and the nature of the relationship between K and Vf. Additionally, there may be a phase lag between the input Vf and output K signals, which can also vary depending on the system dynamics.
Could you find the peaks (crest and trough) of K and then identify two mathematical models that fit the upper and lower envelopes of K? The fitting model for K should be bounded by the mathematical models of the upper and lower envelopes. In fact, the fitting model can be a parametric function of the two envelopes.
Alex Sha
Alex Sha el 10 de Mayo de 2024
@Shubham Your data looks very unreasonable,taking the first 12 sets of data as an example:
a IL Vf k
150 0 0.3 80.62278276
150 0 0.4 65.35516476
150 0 0.5 53.38355585
150 0 0.55 44.04684674
150 0 0.3 93.39806254
150 0 0.4 72.1188811
150 0 0.5 59.5095425
150 0 0.55 49.09761477
150 0 0.3 106.1160211
150 0 0.4 81.98023891
150 0 0.5 67.42473537
150 0 0.55 55.30916884
It can be seen clearly that the values of all "a" and "IL" are same, however, it is strange that the same "Vf" value corresponds to a completely different "k" value,for example, Vf=0.3, corresponded k are 80.62278276, 93.39806254 and 106.1160211, respectively.

Iniciar sesión para comentar.

Categorías

Más información sobre Interpolation 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!

Translated by