Learn R Programming

CircaCP (version 0.1.2)

sleep_detection: Estimate precise sleep_wake cycles using CircaCP algorithm

Description

It first uses a 24 h cosinor fit (via sleep_cos()) and a chosen thresholding rule to label each minute as sleep (label.sw = 1) or wake (label.sw = 0). Reference: Shanshan Chen, and Xinxin Sun.Validating CircaCP: a generic sleep–wake cycle detection algorithm for unlabelled actigraphy data. Royal Society Open Science 11, no. 5 (2024): 231468.

Usage

sleep_detection(clean_df, thr = 0.2, dist = "ZAG")

Value

a data.frame augmenting the input df including the following additional variables:

cosinor

fitted cosine curve

label.cos

circadian cycle estimated by dichotimized cosine curve

label.sw

sleep-wake cycle estimated by CircaCP

Activity_norm

range-normalized activity levels

Arguments

clean_df

Minute-level data.frame with at least Activity. Additional columns are preserved.

thr

Numeric threshold in [0, 1] applied to a rescaled cosinor fit.

dist

Character method key (e.g., "ZAG"); interpreted by your rule set.

See Also

screen_wear(), sleep_cos(),cp_detect(), extract_sleep_metrics()