How to create Multi Linier regression with matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have a coding to cevelop a newe formulation for Xp.
The main task is to calculate Xp, where in general Xp = Xb/Xc. I want to develop new correlation of XbNew, XcNew and XpNew
I want to modify those formultion by adding some parameters.
So XbNew= a1+a2*X3+a3*X4+a4*X5+a5*-X6
and XcNew=b1+b2*X3+b3*X4+b4*X5+b5*-X6
I want to get new function with those formulation XpNew = 1-(c1*XbNew)*exp(-X2/XbNew)+c1*XbNew
Here my coding
%Input File Input Regression(depth,rd,Vs).txt
file1='Input.txt'
fid=fopen(file1, 'r');
RegAll=fscanf(fid,'%g %g %g %g %g %g %g %g %g', [9,Inf])';
X1 =RegAll(:,1);
X2 =RegAll(:,2); % epicentre distance
X3 =RegAll(:,3); % moment magnitude
X4 =RegAll(:,4); % peak ground surface acceleration
X5 =RegAll(:,5);
X6 =RegAll(:,6);
Xb =RegAll(:,7);
Xc =RegAll(:,8);
Xp =RegAll(:,9);
Alpha=log(Xb);
Betha=log(Xc);
Dist=log(X6);
%prepare data for regression Alpha and Betha
X=[X1 X3 X4 X5 X6];
Y=[Xb];
Z=[Xc];
A=X'*X;
K=inv(X'*X)
B=X'*Y
C=X'*Z
K1=K;
a=K*B
b=K1*C
CBetha=K1*C
for i = 1:length(Const);
XbNew(i)= a1+a2*X3(i)+a3*X4(i)+a4*X5(i)+(a5*-X6(i))
XcNew(i)=b1+b2*X3(i)+b3*X4(i)+b4*X5(i)+(b5*-X6(i));
end
X1=[Const XbNew' XcNew'];
Y1=[Xp];
A1=X1'*X1;
K2=inv(X1'*X1)
c=K2*X1*Y1
%
for k=length(AlphaNew)
XpNew = 1-(c1*XbNew)*exp(-X2/XbNew)+c1*XbNew
end
My question is the value of Xb -XbNew and Xc -XcNew are differs
And why inner matrix between K2, X1 and Y1 are not equal.
How to solve my problem. Thnk you for your kind attention I am appreciat to hear any respond.
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Linear and Nonlinear Regression en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!