If you have practise with the post : Tutorials with Resemble (part 1) , you can continue adding more script following the recomendations of the Resemble Package. This time we can add another math treatment to the previous one of the SG filter.
Once applied the "sg" function, we can calculate the
first derivative to define better he variance in the spectra. The Resemble Manual show us how to convert the
spectra to a first derivative using differences. We can do it for the calibration
and the validation sets:
der.Xr <- t(diff(t(Xr), lag = 1,
differences = 1))
der.Xu <- t(diff(t(Xu), lag = 1,
differences = 1))
In this case we
lose a data point on the left of the spectra so we have to define the
wavelengths to see the plot of the first derivative.
wavelength_der<-seq(1112,2488,by=2)
matplot(wavelength_der,t(der.Xr),type="l",col="black",xlab="Wavelength(nm)",ylab="Absorbance")
and we get this plot:
Practise doing the same for the validation set Xu and overplotting the spectra with the training set Xr.
Do you see significant differences?
Enjoy using Chemometrics with R.
No hay comentarios:
Publicar un comentario