决定系数

决定系数,或稱判定系数(英語:Coefficient of determination,记为R 2),在统计学中用于度量應變數的变异中可由自变量解释部分所占的比例,以此来判断迴歸模型的解释力。[1][2][3]

决定系数

R

2

=

1

S

S

res

S

S

tot

{\displaystyle R^{2}=1-{\frac {\color {blue}{SS_{\text{res}}}}{\color {red}{SS_{\text{tot}}}}}}

示意图 线性回归(右侧)的效果比起平均值(左侧)越好,决定系数的值就越接近于1。 蓝色正方形表示线性回归的残差的平方, 红色正方形数据表示对于平均值的残差的平方。

对于简单线性回归而言,决定系数为样本相关系数的平方。[4]当加入其他回归自变量后,决定系数相应地变为多重相关系数的平方。

假设一数据集包括y1,...,yn共n个观察值,相对应的模型预测值分别为f1,...,fn。定义残差ei = yi − fi,平均观察值为

y

¯

=

1

n

i

=

1

n

y

i

.

{\displaystyle {\bar {y}}={\frac {1}{n}}\sum _{i=1}^{n}y_{i}.}

于是可以得到总平方和

S

S

tot

=

i

(

y

i

y

¯

)

2

,

{\displaystyle SS_{\text{tot}}=\sum _{i}(y_{i}-{\bar {y}})^{2},}

残差平方和

S

S

res

=

i

(

y

i

f

i

)

2

=

i

e

i

2

{\displaystyle SS_{\text{res}}=\sum _{i}(y_{i}-f_{i})^{2}=\sum _{i}e_{i}^{2}\,}

由此,决定系数可定义为

R

2

1

S

S

r

e

s

S

S

t

o

t

.

{\displaystyle R^{2}\equiv 1-{SS_{\rm {res}} \over SS_{\rm {tot}}}.\,}