lsp_by_window: Lomb Scargle Periodogram by window

lsp_by_windowR Documentation

Lomb Scargle Periodogram by window


Iteratively computes the Lomb-Scargle periodogram for a time series with irregular (or regular) sampling intervals.


lsp_by_window(df = NULL, windows = NULL, values = NULL,
times = NULL, sampling_rate = NULL,
from = 18, to = 30, type = c("period", "frequency"),
ofac = 60, alpha = 0.01, plot = FALSE)



optional data.frame with 2 or 3 columns. If the data.frame has 2 columns, column 1 contains the windows, column 2 contains the measurement values. If the data.frame has 3 columns, column 1 contains windows, column 2 is POSIXct object, and column 3 is a measurement values.


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. Optional if df is provided.


The data to which we want to find the period. Optional if df is provided.


A POSIXct vector. Optional if df is provided.


A character string indicating the sampling rate of the data. Examples: '30 minutes', '1 hour', '4 seconds', '100 days'.


An optional numeric indicating from which period or frequency to start looking for peaks. Must be in hours. Default = 18.


An optional numeric indicating up to which period or frequency to start looking for peaks. Must be in hours. Default = 30.


Either “frequency” or “period” (default). Determines the type of the periodogram x-axis [lomb::lsp()].


[lomb::lsp()] The oversampling factor. Must be an integer>=1. Larger values of ofac lead to finer scanning of frequencies but may be time-consuming for large datasets and/or large frequency ranges (


A data.frame with the following components:

window A vector containing the window to which the analysis corresponds.

period The period of the timeseries. Outputted in the same sampling rate as the data.

power The maximum power in the frequency/period interval inspected.

lsp_p_value The probability that the maximum peak occurred by chance.

scanned A vector containing the frequencies/period scanned.

normalized_power A vector containing the normalized power corresponding to scanned frequencies/periods.

sig_level Powers > sig.level can considered significant peaks.


lsp_analysis <- lsp_by_window(df = processed_data, sampling_rate = "30 min")

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