aliteimor
(Alex Teymouri)
1
Hi everyone,
I have calculated the autocorrelation function for Istanbul’s monthly rainfall data. The value of this function has reached zero at lag 3.
How do I extract the list of time series for lag1,lag 2, and lag 3 separately? I would like to use these time series as input for prediction modeling.
data0 = WeatherData["Istanbul",
"TotalPrecipitation", {{1970, 1, 1}, {2018, 1, 31}, "Month"}]
Istanbul = QuantityMagnitude[data0["Values"]];
ListLinePlot[Istanbul, PlotRange -> All];
ListPlot[CorrelationFunction[Istanbul, {20}], Filling -> Axis,
PlotRange -> All]
Hi Alex,
Isn’t the lag n time series just this?
Istanbul[[n + 1 ;;]]
aliteimor
(Alex Teymouri)
3
Thank you so much, Rohit.
Let me say my question through the below image with a simple list:
Really I appreciate your help.
Here is one way (not very efficient for long lists)
list = {15, 18, 10, 13, 16, 14, 29, 55};
lag = 3;
lags = Table[ArrayPad[list, {j, 0}, NA], {j, 0, lag}]
lags[[All, lag + 1 ;; Length@list]]
Hi Alex,
The creation of additional lists can be avoided by generating the correct Spans.
list = {15, 18, 10, 13, 16, 14, 29, 55};
lag = 3;
length = Length@list
Table[list[[lag + i ;; length + i - 1]], {i, 1, 1 - lag, -1}]
Encapsulated in a function
ClearAll@lagWindow
lagWindow[list_List, lag_?Positive] /; Length@list > lag :=
Module[{length = Length@list},
Table[list[[lag + i ;; length + i - 1]], {i, 1, 1 - lag, -1}]]
ghorbani
(MA Ghorbani)
6
That’s an awesome solution.
I should say extracting the lag time series is very important in water engineering. Thank you so much, Rohit.
You are always great 