What tool to use to perform Nonlinear Regression with more than 3 variables?

26 visualizaciones (últimos 30 días)
Hi
I am trying to perform a nonlinear regression in Matlab. I have one dependent variale (response) and 16 independent variables (predictors). I am trying to find any tool in Matlab that can perform the nonlinear regression or curve fitting for all of them together.
Is there any such tool in Matlab?

Respuesta aceptada

Star Strider
Star Strider el 13 de Mayo de 2015
The nlinfit function will do what you want.
The procedure for having multiple independent variables is not quite obvious, but easy enough to do. The nonlinear fitting functions will only take one argument for the independent variable, but that argument can be a matrix. To do a nonlinear regression with multiple independent variables, combine your different independent variables into a matrix, and pass that to nlinfit.
For example:
% EQUATION: y = exp(q*x1) * sin(r*x2)
% MAPPING: b(1) = q, b(2) = r, x(:,1) = x1, x(:,2) = x2
x = [x1(:), x2(:)];
f = @(b,x) exp(b(1).*x(:,1)) .* sin(b(2).*x(:,2));
B0 = [1; 1];
B = nlinfit(x, y, f, B0);
(Note: Untested code, for illustration purposes only!)
  1 comentario
Ruby Wei
Ruby Wei el 21 de Jun. de 2020
What if two indepent variables have different dimansions? In this case, they can't be combined into one matrix.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by