R语言-偏最小二乘法回归分析评价-求SSR、SSE、SST以及决定系数R2

入口参数spa

实际输出rawyssr

预测输出fitycode

 1 #pls1是使用偏最小二乘法训练好的模型,使用了17个主成分  2 fity<-pls1[["fitted.values"]][,1,17]  3 #预测值反标准化  4 fity<-(fity+3.239)/1.382
 5 #求检测输出的平均值  6 mean(rawy)->meany  7 #求回归平方和,SSR-Sum of Squares for Regression  8 sum((fity-meany)^2)->y_ssr  9 #求回归残差平方和,SSE-Sum of Squares for Error 10 sum((fity-rawy)^2)->y_sse 11 #求总离差平方和,SST-Sum of Squares for Total 12 y_ssr+y_sse->y_sst 13 #求R2 14 R2<-y_ssr/y_sst
相关文章
相关标签/搜索