cglmm {GLMMcosinor}R Documentation

Fit cosinor model with {glmmTMB}

Description

Given an outcome and time variable, fit the cosinor model with optional covariate effects.

Usage

cglmm(
  formula,
  data,
  family = stats::gaussian(),
  quietly = TRUE,
  dispformula = ~1,
  ziformula = ~0,
  ...
)

Arguments

formula

A formula specifying the cosinor model to be fit. The cosinor portion of the formula is controlled by including amp_acro() on the right hand side of the formula. See amp_acro for more details.

data

A data.frame containing the variables used in the model.

family

A family function or a character string naming a family function. See ?family and ?glmmTMB::family_glmmTMB for options.

quietly

A logical. If TRUE, shows warning messages when wrangling data and fitting model. Defaults to TRUE.

dispformula

A one-sided (i.e., no response variable) formula for dispersion combining fixed and random effects, including cosinor components using amp_acro(). Defaults to ~1.

ziformula

A one-sided (i.e., no response variable) formula for zero-inflation combining fixed and random effects, including cosinor components using amp_acro(). Defaults to ~0.

...

Optional additional arguments passed to glmmTMB::glmmTMB().

Value

Returns a fitted cosinor model as a cglmm object.

References

Tong, YL. Parameter Estimation in Studying Circadian Rhythms, Biometrics (1976). 32(1):85–94.

Examples

# Single component cosinor model
cglmm(
  vit_d ~ amp_acro(time_col = time, group = "X", period = 12),
  data = vitamind
)

# 2-component cosinor model with simulated data
sim_data <- simulate_cosinor(
  n = 500,
  mesor = 5,
  amp = c(2, 1),
  acro = c(1, 1.5),
  beta.mesor = 2,
  beta.amp = c(2, 1),
  beta.acro = c(1, 1.5),
  family = "gaussian",
  period = c(12, 6),
  n_components = 2,
  beta.group = TRUE,
)

cglmm(
  Y ~ group + amp_acro(times,
    n_components = 2,
    group = "group",
    period = c(12, 6)
  ),
  data = sim_data,
  family = gaussian
)

[Package GLMMcosinor version 0.2.0 Index]