## 18 feb. 2018

### PCR vs. PLS (Part 6)

After checking the RMSEP and correlation with different terms in the PCR I get this plot:
using this code:
par(mar=c(5, 4, 4, 6) + 0.1)
plot(Xodd_pcr3,"validation",estimate="CV",

col="blue",ylim=c(0.5,2.5),
xlim=c(1,10),lwd=2,xlab="",ylab="",main="")
par(new=TRUE)
plot(terms,Test_rms,type="l",col="red",ylim=c(0.5,2.5),
xlim=c(1,10),lwd=2,xlab="Nº Terms",

ylab="RMSEP",
main=("CV vs Ext Validation & Corr"))
## Plot the second plot and put axis scale on right
par(new=TRUE)
plot(terms, Test_corr, pch=15,  xlab="", ylab="",

ylim=c(0,1),axes=FALSE, type="b", col="green")
## a little farther out (line=4) to make room for labels
mtext("Correlation",side=4,col="green",line=3)
axis(4, ylim=c(0,1), col="green",

col.axis="green",las=1)
legend("topright",legend=c("CV", "Ext Val","Corr"),
col=c(1:3),lwd=2)
## In the plot 5 seems to be the best option

for the number of terms

Now we can compare the results in the XY plot, as we saw in the post "PCR vs. PLS (part 5)" to get the conclusions.
The statistics for this external validation set with 5 terms are (Monitor function):

```> monitor10c24xyplot(pred_vs_ref_test_5t)
Validation Samples  = 25
Reference Mean  = 45.6236
Predicted Mean  = 46.38495
RMSEP    : 1.046828
Bias     : -0.761354
SEP      : 0.7332779
Corr     : 0.9131366
RSQ      : 0.8338185
Slope    : 0.7805282
Intercept: 9.418837
RER      : 8.115895   Poor
RPD      : 2.428305   Fair
Residual Std Dev is : 0.633808
***Slope/Intercept adjustment is recommended***
BCL(+/-): 0.3020428
***Bias adjustment in not necessary***
Without any adjustment and using  SEP as std dev ```
the residual distibution is: Residuals into 68% prob (+/- 1SEP) = 15 % = 60 Residuals into 95% prob (+/- 2SEP) = 21 % = 84 Residuals into 99.5% prob (+/- 3SEP) = 23 % = 92 Residuals outside 99.5% prob (+/- 3SEP) = 2 % = 8 With S/I correction and using Sres as standard deviation,
the Residual Distribution would be: Residuals into 68% prob (+/- 1Sres) = 20 % = 80 Residuals into 95% prob (+/- 2Sres) = 24 % = 96 Residuals into 99.5% prob (+/- 3Sres) = 25 % = 100 Residuals outside 99.5% prob (> 3Sres) = 0 % = 0