  The attention towards food products characteristics, such as nutritional
properties and traceability, has risen substantially in the recent years.
Consequently, we are witnessing an increased demand for the development of
modern tools to monitor, analyse and assess food quality and authenticity.
Within this framework, an essential set of data collection techniques is
provided by vibrational spectroscopy. In fact, methods such as Fourier near
infrared and mid infrared spectroscopy have been often exploited to analyze
different foodstuffs. Nonetheless, existing statistical methods often struggle
to deal with the challenges presented by spectral data, such as their high
dimensionality, paired with strong relationships among the wavelengths.
Therefore, the definition of proper statistical procedures accounting for the
peculiarities of spectroscopy data is paramount. In this work, motivated by two
dairy science applications, we propose an adaptive functional regression
framework for spectroscopy data. The method stems from the trend filtering
literature, allowing the definition of a highly flexible and adaptive estimator
able to handle different degrees of smoothness. We provide a fast optimization
procedure that is suitable for both Gaussian and non Gaussian scalar responses,
and allows for the inclusion of scalar covariates. Moreover, we develop
inferential procedures for both the functional and the scalar component thus
enhancing not only the interpretability of the results, but also their
usability in real world scenarios. The method is applied to two sets of MIR
spectroscopy data, providing excellent results when predicting milk chemical
composition and cows' dietary treatments. Moreover, the developed inferential
routine provides relevant insights, potentially paving the way for a richer
interpretation and a better understanding of the impact of specific wavelengths
on milk features.
