I need to get the r-square of the model

3 ビュー (過去 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 Center および File ExchangeMarine and Underwater Vehicles についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by