# Comparison of two spectra in order to find whether the irradiated sample has significantly different resulting spectra

I would like to compare two absorption spectra ( or interferograms) and conclude whether between these two there are statistically significant differences at particular wavelength intervals. At the moment, I have data of two experiments that look like this:

    # A tibble: 6 x 5
t     x1     y1     x2     y2
<dbl>  <dbl>  <dbl>  <dbl>  <dbl>
1 3999. 0.0124 0.0132 0.0122 0.0113
2 3998. 0.0125 0.0130 0.0122 0.0116
3 3997. 0.0122 0.0131 0.0122 0.0113
4 3996. 0.0121 0.0136 0.0122 0.0114
5 3995. 0.0124 0.0139 0.0122 0.0122
6 3994. 0.0125 0.0141 0.0122 0.0129


The first column represents the wavenumber, the x columns represent the absorbance of sample and the y columns represent the absorbance of irradiated sample ( before and after). I was wondering whether I could compare these data ( x and y) as time series and if so, what could be the method to quantify the differences, if any, between the samples before and after irradiation. Maybe it's already been done and there is somewhere some information as to how to compare the spectra if the wavenumber is interpreted as time ( x axis). I did the t test in R and in both experiments the null hypothesis could not be rejected, although for the second experiment (x2, y2) the p value was much lower than for the first. If I average the x and y, and then plot both data, I see that there are visible differences at certain wavelength intervals. In R, I used IRISSeismic package and function crossSpectrum, that gave me such an output:

   freq        spec1        spec2 coh        phase             Pxx             Pyy
1   0.0002666667 2.121935e+01 2.152532e+01   1  0.010220252 1.856693e+01+0i 1.883465e+01+0i
2   0.0005333333 7.011069e+00 6.869078e+00   1  0.008984730 6.134686e+00+0i 6.010443e+00+0i
3   0.0008000000 8.385363e+00 8.197039e+00   1  0.011999039 7.337193e+00+0i 7.172409e+00+0i
4   0.0010666667 7.483070e+00 7.272319e+00   1  0.015419031 6.547686e+00+0i 6.363279e+00+0i
5   0.0013333333 4.086251e+00 3.899095e+00   1  0.017551350 3.575469e+00+0i 3.411708e+00+0i
6   0.0016000000 1.537709e+00 1.405562e+00   1  0.008722742 1.345496e+00+0i 1.229867e+00+0i


For all data points the coh index is given as 1. But obviously that doesn't help me to determine, whether the difference is substantial between two data sets. I tried to average data points between groups (x1, y1 and x2, y2) at each wave number and plotted the graph, it looks like the difference might be significant at certain wavenumber interval. Maybe I could try to express one line ( averaged data points after irradiation of the sample) as a function of the other? But how?

Here is a project with similar experiments: https://www.scielo.br/scielo.php?script=sci_arttext&pid=S0103-50532015001202571 , for statistical analysis they use ANOVA and Tukey's test, but how do I do it for the vectored data?

I cannot find online anything. Here is something of the sort I am looking for: https://www.youtube.com/watch?v=gjKSfILE9nM He compares two spectra in Matlab, but he is using self made toolkit which I can not obtain. How can I do something like this in R? I've read something about modelling the data, but here, I don't have any variables just data of two spectra.

• The first thing to do is to know how these measurements are reproducible. If you repeat the first measurement of $\ce{x_1}$ , do you always get $0.0124$ ? This absorbance is extremely weak. Or do you obtain from time to time $0.0122$, then $0.0125$ and $0.0127$ or $0.0123$ ? Are these measured values reliable ? Maybe the six first measurements of $\ce{x_1}$ and $\ce{x_2}$ are all equal. Who knows ? Aug 12 '20 at 16:57
• @Maurice There are intervals that have much larger absorbances. I guess, we could assume that the x2 outputs would be the second given measurement of the same control sample. So, in that case can we produce estimated line for both x and y and then graph error areas to see, whether they overlap? In that case we only have two data points to estimate the approximate point, I guess that's too small. But even so, is this method even legitimate?
– user
Aug 12 '20 at 18:01
• @ User. How were the wavelengths chosen ? Why stop at 3994 ? This is the first time and the only time where an effect can be accepted. Why didn't you not measure at 3993, 3992, then 3980, 3950 ? What is the unit of these wavelengths ? Is it in visible, UV, IR ? Aug 12 '20 at 18:51
• @Maurice Sorry, that I didn't clarify. It's only beginning of the spectra. The spectra is taken from 4000 - 400 cm^-1 . I just put the first few rows, it's IR. The measurements are taken per each wavenumber approximately, the difference between each measurement ~ 0.964
– user
Aug 12 '20 at 19:02
• Does this answer your question? Methods used to compare two spectra in order to determine the effects of irradiation of sample Aug 13 '20 at 14:53