I need to get the r-square of the model

5 Ansichten (letzte 30 Tage)
Javiera Díaz Pavez
Javiera Díaz Pavez am 11 Nov. 2022
Bearbeitet: the cyclist am 11 Nov. 2022
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);

Antworten (1)

the cyclist
the cyclist am 11 Nov. 2022
Bearbeitet: the cyclist am 11 Nov. 2022
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.

Kategorien

Mehr zu Display and Presentation finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by