Second order multiple regression
显示 更早的评论
Hi all !
I'm trying to use 'regress' function to find the best-fit second-order multivariable polynomial equations. It seems most of the online sources are either first-order multiple linear regression or polynomials of only one independent variable. I'm wondering if I use 'regress' to find the best-fit second-order multivariable polynomial equation, is there any possible error even if the matching is accurate (e.g. colinearity maybe?)? What's the principle of 'regress' behind the codes?
Please see below my codes. Es is the dependent variable; mu and G are independent variables. Thank you very much for your answers!
G = [ 3 ;3 ;3 ; 25 ;25 ;25 ; 50 ;50 ;50 ;];
mu = [ 0.15 ;0.50 ;0.90 ; 0.10 ;0.50 ;0.90 ; 0.10 ;0.50 ;0.90 ;];
Es = [ 0.30 ;1.57 ;2.33 ; 0.28 ;2.37 ;4.29 ; 0.34 ;2.66 ;4.70 ;];
%Es = b0 + b1 * G + b2 * G^2 + b3 * mu + b4 * mu^2 + b5 * mu * G
X = [ones(size(G)) G G.^2 mu mu.^2 mu.*G];
b = regress(Es,X);
scatter3(G,mu,Es,'filled')
hold on
x1fit = min(G):2:max(G);
x2fit = min(mu):0.1:max(mu);
[X1FIT,X2FIT] = meshgrid(x1fit,x2fit);
YFIT = b(1) + b(2)*X1FIT + b(3)*X1FIT.^2 + b(4)*X2FIT + b(5)*X2FIT.^2 + b(6)*X1FIT.*X2FIT;
mesh(X1FIT,X2FIT,YFIT)
xlabel('G')
ylabel('\mu')
zlabel('E')
hold off
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Polynomials 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!