How to determine constants using a linear solve of logarithmic transformations which minimize the sum of the residual squares for the below equations?

2 visualizaciones (últimos 30 días)
I have a multivariate power equation in the form y = a1 * (x1^a2) * (x2^a3) * (x3^a4) * (x4^a5) * (x5^a6) , where I have an array of values for each x-term and for the y-term that are each 19775x1. I need to determine the values for the constants a1, a2, a3, a4, and a5 and was told to use a linear solve of logarithmic transformations which minimize the sum of the residual squares. Is there a way to do this in MATLAB?
Attached is my code that I have thus far:
%% Non-dimensional empirical model
% fit used to create correlation:
% pi_theta = a1 .* (pi_y).^a2 .* (pi_z).^a3 .* (pi_twp).^a4 .* ...
% (pi_tcb).^a5 .* (pi_alpha_cb).^a6;
% log10(pi_theta) = log10(a1) + a2 * log10(pi_y) + a3 * log10(pi_z)...
% + a4 * log10(pi_twp) + a5 * log10(pi_tcb) + a6 * log10(pi_alpha_cb);
% solve constants using linear solve of logarithmic transformations of
% above equation.
% a1 =
% a2 =
% a3 =
% a4 =
% a5 =
% a6 =
X = [ones(size(pi_y)), log10(pi_y), log10(pi_z), log10(pi_twp), ...
log10(pi_tcb), log10(pi_alpha_cb)];
Y = log10(pi_theta);
[b, bint,r,rint,stats] = mvregress(Y,X);
I keep getting this error, though:
Error using mvregress (line 456)
Covariance is not positive-definite.
Error in Dimensionless_parameters_analysis (line 266)
[b, bint,r,rint,stats] = mvregress(Y,X);

Respuesta aceptada

Star Strider
Star Strider el 3 de Jul. de 2019
REPOSTED —
I decided to let ga have a go at your data and function.
This code :
D = load('X-Y.mat ');
X = D.X ;
Y = D.Y;
objfcn = @(a,x) a(1) .* (x(:,1).^a(2)) .* (x(:,2).^a(3)) .* (x(:,3).^a(4)) .* (x(:,4).^a(5)) .* (x(:,5).^a(6 ));
ftns = @(a) norm(Y - objfcn(a,X));
PopSz = 500 ;
Parms = 6 ;
opts = optimoptions('ga', 'PopulationSize',PopSz, 'InitialPopulationMatrix',randi(1E+4,PopSz,Parms)*1E-1, 'MaxGenerations',2E3, 'PlotFcn',@gaplotbestf, 'PlotInterval',1 );
[theta,fval,exitflag,output] = ga(ftns, Parms, [],[],[],[],zeros(Parms,1),Inf(Parms,1),[],[],opts )
converged fairly quicklly (00:06:21) in 407 generations to produce these parameter estimates :
Parameters =
1.0e+02 *
0.002865234375000
8.700138633728027
0.027473449707031
0.009913467407227
0.000003921508789
0.002913574218750
with a fitness value :
fval =
66.598426312801081
that is also the best of several runs, each with different 'InitialPopulationMatrix' amplitudes. The predicted ‘Y’ values are all complex.
  2 comentarios
Geoff Doback
Geoff Doback el 3 de Jul. de 2019
Editada: Geoff Doback el 3 de Jul. de 2019
Thank you, sir! I actually found a flaw in my original data and fixed it, and this worked perfectly!
Star Strider
Star Strider el 3 de Jul. de 2019
As always, my pleasure!
I very much appreciate your contacting me and asking me to re-post my Answer.

Iniciar sesión para comentar.

Más respuestas (1)

Matt J
Matt J el 28 de Jun. de 2019
Editada: Matt J el 28 de Jun. de 2019
The fit is ill-posed (has infinite solutions) because your data pi_tcb is basically 3.2 times pi_tmp:
pi_tcb=10.^(X(:,5));
pi_twp=10.^(X(:,4));
>> norm(pi_tcb-3.2*pi_twp)
ans =
1.906978550450982e-14

Community Treasure Hunt

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

Start Hunting!

Translated by