0

I am trying to find a function that matches two time series such that the datetime corresponds to reality.

So I need a function that minimizes the distance between the two curves shown above and outputs a new dataframe that has TAIR time-shifted towards the values of tre200h0.

From my bare eyes, it looks like this shift is about 22h.

ggplot

Best,

Fabio

I don't know a function that does this job for me.

Cla FM
  • 11
  • 3
  • Two R base functions to analyze time series lags are `acf` and `pacf`. i.e. given you have x and y you can use `acf(y-x)` and seek the zeroes in the plot (if your series have adequate seasonal behaviour), or, if you prefer, `acf(y-x, plot=F)` and get the data. Try `which.min( acf(x-y)$acf^2 )`. Of course, it is a simplification of otherwise complex matter. – Ric Nov 07 '22 at 13:08
  • Thanks this should solve it! The shift was exactley 22 hours, but this can be useful for future reference. F. – Cla FM Nov 08 '22 at 16:13

1 Answers1

0

Solved by Ric Villalba in the comments to OG Question.

Two R base functions to analyze time series lags are acf and pacf. i.e. given you have x and y you can use acf(y-x) and seek the zeroes in the plot (if your series have adequate seasonal behaviour), or, if you prefer, acf(y-x, plot=F) and get the data. Try which.min( acf(x-y)$acf^2 ).

Of course, it is a simplification of otherwise complex matter

Indiano
  • 684
  • 5
  • 19
Cla FM
  • 11
  • 3