tft每日頭條

 > 生活

 > 線性回歸方程r的取值

線性回歸方程r的取值

生活 更新时间:2024-07-06 22:40:58

決定系數(coefficient ofdetermination),有的書上翻譯為判定系數,也稱為拟合優度。

決定系數反應了y的波動有多少百分比能被x的波動所描述,即表征依變數Y的變異中有多少百分比,可由控制的自變數X來解釋.

表達式:R方=SSR/sst=1-SSE/SST

其中:SST=SSR SSE,SST(total sum of squares)為總平方和,SSR(regression sum of squares)為回歸平方和,SSE(error sum of squares) 為殘差平方和。

回歸平方和:SSR(Sum of Squares forregression) = ESS (explained sum of squares)

殘差平方和:SSE(Sum of Squares for Error) = RSS(residual sum of squares)

總離差平方和:SST(Sum of Squares fortotal) = TSS(total sum of squares)

SSE SSR=SST RSS ESS=TSS

線性回歸方程r的取值(線性回歸決定系數R方的計算方法及具體意義)1

意義:拟合優度越大,自變量對因變量的解釋程度越高,自變量引起的變動占總變動的百分比高。觀察點在回歸直線附近越密集。取值範圍:0-1.

舉例:

假設有10個點,如下圖:

線性回歸方程r的取值(線性回歸決定系數R方的計算方法及具體意義)2

用R來實現如何求線性方程和R2:

# 線性回歸的方程

mylr = function(x,y){

plot(x,y)

x_mean = mean(x)

y_mean = mean(y)

xy_mean = mean(x*y)

xx_mean = mean(x*x)

yy_mean = mean(y*y)

m = (x_mean*y_mean - xy_mean)/(x_mean^2 - xx_mean)

b = y_mean - m*x_mean

f = m*x b# 線性回歸方程

lines(x,f)

sst = sum((y-y_mean)^2)

sse = sum((y-f)^2)

ssr = sum((f-y_mean)^2)

result = c(m,b,sst,sse,ssr)

names(result) = c('m','b','sst','sse','ssr')

return(result)

}

x = c(60,34,12,34,71,28,96,34,42,37)

y = c(301,169,47,178,365,126,491,157,202,184)

f = mylr(x,y)

f['m']

f['b']

f['sse'] f['ssr']

f['sst']

R2= f['ssr']/f['sst']

最後方程為:f(x)=5.3x-15.5

R2為99.8,說明x對y的解釋程度非常高。

線性回歸方程r的取值(線性回歸決定系數R方的計算方法及具體意義)3

本期課程就到這裡哦,感謝大家耐心觀看!每日更新,敬請關注!

【杏花開生物醫藥統計】微信公衆号(xhkdata)

線性回歸方程r的取值(線性回歸決定系數R方的計算方法及具體意義)4

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关生活资讯推荐

热门生活资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved