Nonlinear regression with two variables

Hello all, I want to fit a nonlinear model to a set of experimental data. It has 1 dependent variable, Y, and 2 indepenent variables, X1 and X2.
I have this equation. Y = C * ((X1)^1/2 * (X2)^a. I'd like to determine the values of the parameters, C and a.
X1 = QG_Lmin.*1.67*10^-5;
X2 = QG_Lmin ./ QL;
% Define the model function
model = @(coefficients, x) coefficients(1) * sqrt(x(:, 1)) .* x(:, 2).^coefficients(2);
% Define the initial parameter values
initialCoefficients = [1, 1];
% Perform nonlinear regression using lsqcurvefit
estimatedCoefficients = lsqcurvefit(model, initialCoefficients, [X1, X2], Y);
% Extract C and a from the estimated coefficients
C = estimatedCoefficients(1);
a = estimatedCoefficients(2);
But I got an error:
Initial point is a local minimum.
Optimization completed because the size of the gradient at the initial point
is less than the value of the optimality tolerance.
<stopping criteria details>
Could anyone help me out?

Respuestas (1)

Torsten
Torsten el 29 de Jun. de 2023
Editada: Torsten el 29 de Jun. de 2023
I don't know your inputs, but theoretically, it works:
X = rand(50,2);
Y = rand(50,1);
% Define the model function
model = @(coefficients, x) coefficients(1) * sqrt(x(:, 1)) .* x(:, 2).^coefficients(2);
% Define the initial parameter values
initialCoefficients = [1, 1];
% Perform nonlinear regression using lsqcurvefit
estimatedCoefficients = lsqcurvefit(model, initialCoefficients, X, Y);
Local minimum possible. lsqcurvefit stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
% Extract C and a from the estimated coefficients
C = estimatedCoefficients(1)
C = 0.8608
a = estimatedCoefficients(2)
a = 0.2220
Maybe your arrays X1 and X2 contain NaN or Inf values.

Preguntada:

el 29 de Jun. de 2023

Editada:

el 29 de Jun. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by