cosinor_lm: Cosinor Analysis

View source: R/cosinor_lm.R

cosinor_lmR Documentation

Cosinor Analysis

Description

COSINOR analysis of a timeseries.

Usage

cosinor_lm(df = data, timeseries_datetime = NULL, values = NULL, sampling_rate = "30 min", period = 48, na.action = na.omit)

Arguments

df

A data.frame which contains the dates of a time series in column 1 and the values in column 2.

timeseries_datetime

A vector of class POSICXct which contains the dates over which to run a COSINOR analysis.

values

The data to which we want to find the period.

sampling_rate

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

period

A numeric indicating the period to analyse. Must be in the same units as the sampling rate. Examples: If the goal is to evaluate a 24 "hour" period but the sampling rate is "30 minutes", the period to use is a 48 "30 minutes" period.

na.action

Default is na.omit which excludes NA values from the analysis. See [stats::lm()] for a more detailed description.

Value

A data.frame with: MESOR: The intercept of the regression. ie. Mean of the COSINOR fit. Amplitude: Amplitude of the COSINOR fit. Amplitude_se Acrophase: Phase shifting of the fit in radians. Acrophase_se Phase_in_seconds: Acrophase in seconds. Phase_se_seconds Adj_r_squared: The PR or Percent Rythm of the fit. Cosinor_p_value: p.value for the regression. Significance indicates the period matches the data. Wave_y = MESOR + amplitude * cosw : The use is to plot the fit. Wave_x = timeseries_datetime + phase_in_seconds : The use is to plot the fit.

See Also

Barnett, A. G., & Dobson, A. J. (2010). Analysing Seasonal Health Data. Statistics for Biology and Health. doi:10.1007/978-3-642-10748-1

Tong, Y. L. (1976). Parameter Estimation in Studying Circadian Rhythms. Biometrics, 32(1), 85. doi:10.2307/2529340

Examples

cosinor <- cosinor_lm(df = data, sampling_rate = "30 min", period = 48)


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