# How to align data series along x-Axis to achieve besst fit?

I have 4 datasets that I am trying to align to each other so I can so some further analysis. I asked a similar question earlier, that didn't get much attention, so I am trying again (this time with different data).

My data is available here. In the reference set, d18O is the "reference" Y-Axis, rel_scale is the "reference" x-Axis, and the Date column is what ultimately want to assign to my other data. In the data-to-align set, distance is the raw measurement distance, rel_scale is the distance relatively scaled to yearly growth periods -> the x-axis to align to the reference. d18O is the dependent variable again.

the first dataset are measured temperatures, and salinity of a location over time (so a time series), which are displayed in red and blue in the upper plot.

For the same time period I measured chemical parameters (here d18O) in 3 bivalve shells (datasets 2-4) and I am trying to align it to the instrumental temperatures. They are displayed in the 3 lower plots. For that reason I already calculated a d18O from the instrumental temperatures folloiwng some equation (black line upper plot).

The reason I want to align modeled d18O and measured d18O in bivalves is, that I want to assign a timestamp to each position in the shell. Right now the x-Axis fo the lower 3 plots really is Distance between measurements in mm. Because the shells grow faster and slower depending on the season, I want to detrend this data to refer to actual calendar dates. So I want to transform my x-Axes to achieve best fit with the black plot in the top curve.

I read a bit into DTW and similar methods, but I just can't find a solution because my knowledge on math and statistics like this is limited. My big problem is that sampling period and frequency are varying.

If I put the curves on top of each other it looks like this:

which Is already a good fit but still not optimal (see the seasonal bumps that dont quite align. Another reason I want to detrend this data for growth rate is that I could not the "displacement factor" of each measurement and possibly reconstruct how fat or slow the bivalves grow during each month.

I hope someone can point me to methods / resources / procedures to use for this problem, or alternatively show me where I am overcompicating things and point me to easier methods for detrending fluctuating sampling rates. I'm always here to answer questions you might have about my data.

Best regards.

• Now that you've asked this, you should delete the previous version. – Nick Cox Apr 15 at 10:35