Skip to contents

Checks the validity of user inputs before creating an updated formula and associated modifications to the data.frame.

Usage

amp_acro(time_col, n_components = 1, group, period, ...)

Arguments

time_col

A numeric column within the data.frame() passed by via the data arg containing the time values.

n_components

The Number of cosinor components in the model.

group

A vector of the names for the group factors (column names within the data.frame() passed by via the data arg).

period

A numeric value or vector containing the period. The number of values should be equal to n_components.

...

Extra arguments for use within GLMMcosinor.

Value

A data.frame and formula appropriate for use by data_processor().

Examples

# Single component cosinor model
cglmm(
  vit_d ~ amp_acro(time_col = time, group = "X", period = 12),
  data = vitamind
)
#> 
#>  Conditional Model 
#> 
#>  Raw formula: 
#> vit_d ~ X:main_rrr1 + X:main_sss1 
#> 
#>  Raw Coefficients: 
#>              Estimate
#> (Intercept)  30.32687
#> X0:main_rrr1  0.86520
#> X1:main_rrr1  6.47625
#> X0:main_sss1  6.24438
#> X1:main_sss1  4.66701
#> 
#>  Transformed Coefficients: 
#>             Estimate
#> (Intercept) 30.32687
#> [X=0]:amp    6.30404
#> [X=1]:amp    7.98266
#> [X=0]:acr    1.43312
#> [X=1]:acr    0.62444

# 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
)
#> 
#>  Conditional Model 
#> 
#>  Raw formula: 
#> Y ~ group + group:main_rrr1 + group:main_sss1 + group:main_rrr2 +      group:main_sss2 
#> 
#>  Raw Coefficients: 
#>                  Estimate
#> (Intercept)       4.94999
#> group1           -2.88638
#> group0:main_rrr1  1.04190
#> group1:main_rrr1  1.02509
#> group0:main_sss1  1.71963
#> group1:main_sss1  1.63070
#> group0:main_rrr2  0.04703
#> group1:main_rrr2  0.08070
#> group0:main_sss2  1.01121
#> group1:main_sss2  1.09037
#> 
#>  Transformed Coefficients: 
#>                Estimate
#> (Intercept)     4.94999
#> [group=1]      -2.88638
#> [group=0]:amp1  2.01064
#> [group=1]:amp1  1.92614
#> [group=0]:amp2  1.01231
#> [group=1]:amp2  1.09335
#> [group=0]:acr1  1.02606
#> [group=1]:acr1  1.00960
#> [group=0]:acr2  1.52432
#> [group=1]:acr2  1.49692