## 30 ene. 2018

### Trying to understand the regression coefficients

When developing the regression protein in R, one of the values obtained are the regression coefficients which are used to calculate the protein value for every new sample. There is a regression coefficient for every wavelength, so we can make a plot for the regression coefficients which maybe help us to understand how the calibration is working, but is not always like this and sometimes are very difficult to understand or almost impossible.
In the case of the regression make (with 4 terms) for the soy meal in transmittance, we can see the coefficient values like this.
attach(Prot_plsr_r1)
coefficients[,,4]
wavelengths<-as.matrix(seq(850,1048,by=2))
matplot(wavelengths,coefficients[,,4],type="l",

xlab="wavelengths",ylab="coefficients")
We can look for the peaks:
library(quantmod)
findPeaks(coefficients[,,4])

The results are that we have peaks at:

`soy_ift_prot1r1\$X_msc.....880nm  (Starch band)`

soy_ift_prot1r1\$X_msc.....910nm  (Protein band)

soy_ift_prot1r1\$X_msc.....968nm  (Fat band)
soy_ift_prot1r1\$X_msc....1028nm  (Protein / Fat band)
The results make some sense and make me a little more confident that the regression will work fine in routine.