matlab中的r平方是什么意思,R平方:判定系数

R平方是衡量数据拟合模型效果的指标,它比较了预测误差的方差与原始数据的方差。RSQUARE函数计算R平方值,并提供均方根误差(RMSE)。如果模型不含常数项,R平方可能不是合适的拟合度量。示例展示了如何使用RSQUARE计算R平方和RMSE。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

R-square: The coefficient of determination

Compute coefficient of determination of data fit model and RMSE

[r2 rmse] = rsquare(y,f)

[r2 rmse] = rsquare(y,f,c)

RSQUARE computes the coefficient of determination (R-square) value from

actual data Y and model data F. The code uses a general version of

R-square, based on comparing the variability of the estimation errors

with the variability of the original values. RSQUARE also outputs the

root mean squared error (RMSE) for the user's convenience.

Note: RSQUARE ignores comparisons involving NaN values.

INPUTS

Y : Actual data

F : Model fit

OPTION

C : Constant term in model

R-square may be a questionable measure of fit when no

constant term is included in the model.

[DEFAULT] TRUE : Use traditional R-square computation

FALSE : Uses alternate R-square computation for model

without constant term [R2 = 1 - NORM(Y-F)/NORM(Y)]

OUTPUT

R2 : Coefficient of determination

RMSE : Root mean squared error

EXAMPLE

x = 0:0.1:10;

y = 2.*x + 1 + randn(size(x));

p = polyfit(x,y,1);

f = polyval(p,x);

[r2 rmse] = rsquare(y,f);

figure; plot(x,y,'b-');

hold on; plot(x,f,'r-');

title(strcat(['R2 = ' num2str(r2) '; RMSE = ' num2str(rmse)]))

Jered R Wells

11/17/11

jered [dot] wells [at] duke [dot] edu

v1.2 (02/14/2012)

Thanks to John D'Errico for useful comments and insight which has helped

to improve this code. His code POLYFITN was consulted in the inclusion of

the C-option (REF. File ID: #34765).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值