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

25 Ansichten (letzte 30 Tage)
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?

Akzeptierte Antwort

Star Strider
Star Strider am 13 Mai 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 Kommentar
Ruby Wei
Ruby Wei am 21 Jun. 2020
What if two indepent variables have different dimansions? In this case, they can't be combined into one matrix.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by