I need to get the r-square of the model

2 次查看(过去 30 天)
Hi, I need to get the r-square of the model I made. It contains 3 variables (x,y,z). I don't know how to use matlab so I turn to the community, because I don't understand the answers from other forums. PLEASE HELP ME :(
(I use Matlab R2019a)
clear;
pga_x = load('PGA.txt'); %Text file with 115 data
clt_y= load('CLT.txt'); %Text file with 3 data
costo_z=load('COSTOFEMA.txt'); %Text file with 115 data
%c1_z= costo_z(:,1);
%c2_z= costo_z(:,2);
%c3_z= costo_z(:,3);
%c4_z= costo_z(:,4);
[xdata, ydata, zdata] = prepareSurfaceData(pga_x, clt_y, costo_z);
sf = fit([xdata, ydata], zdata, 'poly11');
disp(sf);
a = plot(sf,[xdata, ydata], zdata);
hold on
legend( a, 'Ajuste de curva Lineal', '%CLT vs. PGA(g), Costo US($)', 'Location', 'NorthEast' );
xlabel('PGA (g)');
ylabel('%CLT');
zlabel('Costo de reparación US $');
colormap(cool);

回答(1 个)

the cyclist
the cyclist 2022-11-11
编辑:the cyclist 2022-11-11
Instead of calling the fit function with one output
sf = fit([xdata, ydata], zdata, 'poly11');
call it with two outputs
[sf, gof] = fit([xdata, ydata], zdata, 'poly11'); % Get goodness-of-fit output
and then
gof.rsquare
should give you the R^2 value. This is described in the Output Arguments section of the documentation of the fit function.

类别

Help CenterFile Exchange 中查找有关 Display and Presentation 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by