I need to get the r-square of the model

조회 수: 2 (최근 30일)
Javiera Díaz Pavez
Javiera Díaz Pavez 2022년 11월 11일
편집: the cyclist 2022년 11월 11일
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