回复 第3楼 的 reader0527:
你说得确实有道理,但是我不知道MSE是否可以直接计算出来?且我不知道你采取的R方定义是哪一个,
我知道的R方定义是 R2=1-(SSre/SStot)
SSre 是 the sum of the squares of the distances of the points from the fit.
SStot是 the sum of the squares of the distances of the points from a horizontal line through the mean of all Y values.
然后可以非常简单的计算如下:
回复 第4楼 的 lizijing5551:
根据上面的定义,在你的情况下,你可以计算如下:
# 得到fitted value<br />
fit<-fitted(Reg)<br />
SSre<-sum((z$V-fit)^2)<br />
#或者<br />
SSre<-sum(residuals(Reg)^2)</p>
<p>SStot<-sum((z$V-mean(z$V)^2)<br />
R2=1-SSre/SStot<br />
</p>