This time I´m going to use my own data to develop a model to predict some fatty acid in the solid fat (pork).
Samples had been analyzed in a NIT (Near Infrared Transmittance) instrument. The range of the wavelengths is from 850 to 1048 nm (100 data points). This area cover usually second overtones.
I am quite novice in R, and it takes some time (in my case) to have the data organize in R to starts working with it.
We have together the X matrix (NIT absorbance’s) with the Y matrix (constituents). First of all was to import the”txt” file and create a data frame.
The TXT file has been exported from the software of the instrument.
 "C16_0" "C16_1" "C18_0" "C18_1" "C18_2" "C18_3" "NIT"
At this point we are ready to see the raw spectra.
We can see a high scatter, so a remove scatter pretreatment is necessary. Let´s try the MSC.
First we have to prepare the data, if not we will get some errors: