Learn R Programming

CircaCP (version 0.1.2)

sleep_cos: Estimates circadian cycle by cosinor fit of minute-level activity (period = 1440)

Description

Fits \(C(t) = m + a \cos\{2\pi (t - \phi)/P\}\) with period \(P = 1440\) minutes to a rescaled activity series. Returns fitted curve, binary curve after thresholding, and canonicalized parameters (non-negative amplitude). MESOR (mesor) The baseline or “midline” level around which the rhythm oscillates. Units = same as actigraphy your data Roughly the average activity across the cycle.

Usage

sleep_cos(clean_df, thr = 0.2)

Value

A list with elements:

fitted

fitted cosine curve.

label.cos

dichotimized cosine curve

cos_para

c(Mesor, Amplitude, Acrophase).

rmse

Root mean squared error between fitted cosine curve and data.

Arguments

clean_df

cleaned dataframe with cleaned_df$Activity.

thr

Dichotomization threshold for fitted curve.

Details

Amplitude (amp) Half the peak-to-trough swing of the fitted rhythm. Units is the same as actigraphy data. Larger amplitude → stronger rhythmicity (bigger day–night contrast). Negative amp will be flipped, and P/2 will be added to phase. Acrophase (phase) The timing of the peak of the fitted cosine. Units is the epoch units of the data (e.g. minutes). P=1440, interpret phase as minutes-of-day relative to your x origin.

See Also

screen_wear(), sleep_detection(), extract_sleep_metrics()