acf_window: Auto Correlation with a moving window

View source: R/acf_window.R

acf_windowR Documentation

Auto Correlation with a moving window


Uses autocorrelation to find a circadian period for a given timeseries


function(df = NULL,  from = 18, to = 30,
sampling_rate = "1 hour", window_vector = NULL, values = NULL)



A data.frame with 2 columns. Column 1 must contain the windows to iterate over. Column 2 must supply the values. This parameter is optional if window_vector and values are supplied. df must not have gaps in the dates, acf asumes data is evenly spaced.


The period (in hours) from which to start looking for peaks in the autocorrelation. Default = 18.


The period (in hours) up to which to look for peaks in the autocorrelation. Default = 30.


A charater string which indicates the sampling rate of the data. For example: "1 second", "2 minutes", "1 hour" (default),"3 days", "11 months".


A vector containing the windows to iterate over and to label the group to which each value belongs. Usually this will be the output from make_time_windows.


The data for which we want to find the period.


A data.frame with the autocorrelation results for each window which include: period, peaks, power, lags for the peaks.

See Also

[stats::acf()] which this functions uses to run the autocorrelation.


autocorrelations_multipeak <- acf_window(df = df_with_windows,
multipeak_period = FALSE, peak_of_interest = 2,
sampling_unit = "hours")

edpclau/circadian-dynamics documentation built on Aug. 25, 2023, 12:18 p.m.