analyze_cosinor_design: Analyze Cosinor Design

View source: R/pwutilityfunctions.R

analyze_cosinor_designR Documentation

Analyze Cosinor Design

Description

This function analyzes a vector of time points and computes various metrics related to periodic sampling. It handles both absolute and modulo-per time representations.

Usage

analyze_cosinor_design(timepoints, per = 24, accuracy = 1e-04)

Arguments

timepoints

A numeric vector of time points to analyze.

per

The cosinor period

accuracy

Absolute accuracy for determining centeredness and phase invariance

Details

The function performs several analyses on the provided time points:

  • Computes the number of replicates for each unique time point.

  • Computes the number of unique time points and replicates modulo per.

  • Checks for balance in replicates, sampling intervals, and distribution within a cycle.

Value

An object of class cosinor_design containing the following elements:

n_points

The total number of time points.

n_uniq

The number of unique time points (sorted).

reps

A vector indicating the number of replicates per unique time point (sorted).

reps_uniq

A vector of unique replicate counts across all time points.

n_unique_modper

The number of unique time points within a per-hour cycle.

reps_modper

A vector of replicate counts per unique time point modulo per.

reps_modper_uniq

A vector of unique replicate counts across all time points modulo per.

sampling_int_uniq

A vector of unique sampling intervals between consecutive time points (sorted).

tps_sorted

A vector of the input time points sorted in ascending order.

tps_modper_sorted

A vector of the time points modulo per, sorted.

input_sort_idx

The index mapping the original input time points to the sorted time points.

input_to_modper_idx

The index mapping the original input time points to the sorted modulo-per time points.

equal_reps

Logical, indicating whether the number of replicates per unique time point modulo per is identical.

evenly_spaced

Logical, indicating whether time points are evenly spaced within a cycle, also considering wrap-around from end to beginning.

is_centered

Logical, indicating whether the design is centered. Centered designs potentially reach the highest power.

is_phaseinv

Logical, indicating whether the design is phase-invariant. Phase-invariant designs lead to power independent of phase.

Examples

# Simulate a time point vector
set.seed(123)
timepoints <- rep(seq(0, 44, by = 4), each = 3) |> sample()

# Analyze time points
results <- analyze_cosinor_design(timepoints)

# View results
print(results)


powestermark/pwrutilities documentation built on Dec. 28, 2024, 4:44 a.m.