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

constant determinationMATLABmultivariate linear regressionmultivariate power equationmultivariate regressionmvregress()regress

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 19775×1. 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);

Best Answer

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.
Related Question