Non-linear Multivariate regression using genetic algorithm
26 views (last 30 days)
I would like to perform non-linear multivariate regression using genetic algorithm in matlab.
I have five independent variables and one response. How can I do non-linear regression by minimizing the mean square error in matlab using genetic algorithm?
R = f (x1, x2, x3, x4)
I want to fit the data to the equation similar to the following:
Thus, my objective is to find the constants C1, C2, C3,..., C21 using the GA in matlab by minimizing the difference between the actual response and the response from the model.
Star Strider on 19 Jan 2020
One (very basic) approach:
xd = rand(10,1); % Create Dependent Variable
xi = rand(10,4); % Create Independent Variable Matrix
R = @(b,x) b(1).*sin(b(2).*x(:,1)) + b(3).*exp(b(4).*x(:,2)) + b(5).*cos(b(6).*x(:,3)) - b(7).*x(:,4); % Objective Function
ftnsfcn = @(b) norm(xd - R(b,xi)); % Fitness Function
B = ga(ftnsfcn, 7); % Genetic Algorithm Call
The idea is to create a matrix of the independent variables, then refer to them by their respective columns (my preference).
There are many ways to customise the ga population and other parameters to get interim outputs and create a specific initial population, among others. The ga function will search the parameter space for the best set, so being rigorous about defining a range for them is only necessary if they are widely varying in their expected amplitudes.
More Answers (1)
Alex Sha on 28 Jan 2020
The GA toolbox in Matlab is not an ideal tool for curve fitting with the goal of global optimizatiom result. Refer the result below, it should be the global solution which GA may never get.
Root of Mean Square Error (RMSE): 0.00114090675219561
Sum of Squared Residual: 0.000298082021740069
Correlation Coef. (R): 1
Adjusted R-Square: 1
Determination Coef. (DC): 1
Parameter Best Estimate