Closed serbinsh closed 3 years ago
Crap, we also need to do this for the calibration plot stats
cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps],2)
this needs to be
cal.R2 <- round(pls::R2(plsr.out)[[1]][nComps+1],2)
Actually the most appropriate way is to use
pls::R2(plsr.out,newdata=val.plsr.data, intercept = F)
intercept =F
I ll check if this is the issue I had, I finally used the lm function to compute the R2 and RMSE and thought to check what was the difference later. I also had negative R2 using pls::R2 which makes no sense to me, so I wonder if it is an issue with pls:R2 or if we did something wrong. See for example: https://github.com/TESTgroup-BNL/Physiological_traits_PLSR_models/blob/master/PLSR_models/Validation_PuertoRico2017%202021-04-20.pdf . It looks like I had issue when the performance of the model was not very good (for example R2 with lm below 0.6) and a lot of components. We do have an intercept in our models so I am not sure if we need to use nComps+1? Ill check later today or tommorow
Developing a small PR to address this issue.
In our example scripts, particularly when we create the side-by-side cal/val plots
I found a bug where the R2 doesn't match the R2 in the final validation plot
Thats because for the cal/val plotting we are putting in R2 using
but that doesn't account for the fact that the intercept is included so instead of say giving me the results for nComp=5 its giving me the value at ncomp=4. We need to do
which is what we do for the validation plot. So we need to make a change in our scripts to address this and re-run the examples :/
@julien is this also what you saw? Or was that a different issue?