Model specification

library(GLMMcosinor)
library(dplyr)

cglmm()

cglmm() wrangles the data appropriately to fit the cosinor model given the formula specified by the user. It provides estimates of amplitude, acrophase, and MESOR (Midline Statistic Of Rhythm).

The formula argument for cglmm() is specified using the {lme4} style (for details see vignette("lmer", package = "lme4")). The only difference is that it allows for use of an amp_acro() call within the formula that is used to identify the circadian components and relevant variables in the data.frame. Any other combination of covariates can also be included in the formula as well as random effects and zero-inflation (ziformula) and dispersion (dispformula) formulae. For detailed examples of how to specify models, see the mixed-models, model-specification and multiple-components vignettes.

Using cglmm()

The following examples use data simulated by the the simulate_cosinor function.

Specifying a single-component model with no grouping variable

Here, we fit a simple cosinor model to “testdata_simple” - simulated data from a Poisson distribution loaded in this vignette. In this example, there is no grouping variable.

testdata_simple <- simulate_cosinor(
  1000,
  n_period = 2,
  mesor = 5,
  amp = 2,
  acro = 1,
  beta.mesor = 4,
  beta.amp = 1,
  beta.acro = 0.5,
  family = "poisson",
  period = c(12),
  n_components = 1,
  beta.group = TRUE
)
object <- cglmm(
  Y ~ amp_acro(times,
    period = 12
  ),
  data = filter(testdata_simple, group == 0),
  family = poisson()
)
object
#> 
#>  Conditional Model 
#> 
#>  Raw formula: 
#> Y ~ main_rrr1 + main_sss1 
#> 
#>  Raw Coefficients: 
#>             Estimate
#> (Intercept)  4.99845
#> main_rrr1    1.08228
#> main_sss1    1.68235
#> 
#>  Transformed Coefficients: 
#>             Estimate
#> (Intercept)  4.99845
#> amp          2.00041
#> acr          0.99913

The output shows the estimates for the raw coefficients in addition to the transformed estimates for amplitude (amp) and acrophase (acr) and MESOR ((Intercept)). The previous section of this vignette: An overview of the statistical methods used for parameter estimation outlines the difference between the raw coefficients and the transformed coefficients.

We would interpret the output as follows:

  • MESOR estimate = 4.99845

  • Amplitude estimate = 1.08228

  • Acrophase estimate = 0.99913

Note that this estimate is in radians to align with conventions. To interpret this, we can express 0.99913 radians as a fraction of the total 2π and multiply by the period to get the time when the response is a maximal. Hence, $\frac{0.99913}{2\pi} \times 12 = 1.908$ in the units of the time_col column in the original dataframe. This is saying that the peak response would occur after 1.908 time-units and every 12 time-units after this. We can confirm this by plotting:

autoplot(object, superimpose.data = TRUE)

Specifying a single-component model with a grouping variable and a shared MESOR

Now, we can add a grouping variable by adding the name of the group in the amp_acro() function:

testdata_simple_gaussian <- simulate_cosinor(
  1000,
  n_period = 2,
  mesor = 5,
  amp = 2,
  acro = 1,
  beta.mesor = 4,
  beta.amp = 1,
  beta.acro = 0.5,
  family = "gaussian",
  period = c(12),
  n_components = 1,
  beta.group = TRUE
)
object <- cglmm(
  Y ~ amp_acro(times,
    period = 12,
    group = "group"
  ),
  data = testdata_simple_gaussian,
  family = gaussian
)
object
#> 
#>  Conditional Model 
#> 
#>  Raw formula: 
#> Y ~ group:main_rrr1 + group:main_sss1 
#> 
#>  Raw Coefficients: 
#>                  Estimate
#> (Intercept)       4.47411
#> group0:main_rrr1  1.03269
#> group1:main_rrr1  0.90209
#> group0:main_sss1  1.67745
#> group1:main_sss1  0.48497
#> 
#>  Transformed Coefficients: 
#>               Estimate
#> (Intercept)    4.47411
#> [group=0]:amp  1.96984
#> [group=1]:amp  1.02419
#> [group=0]:acr  1.01896
#> [group=1]:acr  0.49328

In the example above, the amplitude and phase are being estimated separately for the two groups but the intercept term is shared. This represents a shared estimate of the MESOR for both groups and is useful if two groups are known to have a common baseline (or equilibrium point). Hence, we would interpret the transformed coefficients as follows:

  • The MESOR estimate is 4.47411 for both group = 0 and group = 1.

  • The estimates for amplitude and acrophase are with reference to the a MESOR estimate of 4.47411

autoplot(object)

However, the groups in this dataset were simulated with two different MESORs, and so it would be more appropriate to specify an intercept term in the formula, as this will estimate the MESOR for both group = 0 and group = 1:

Specifying a single-component model with a grouping variable and an intercept (MESOR)

Similarly to a normal regression model with {lme4} or {glmmTMB}, we can add a term for the group in the model so that we can estimate the difference in MESOR between the two groups.

object <- cglmm(
  Y ~ group + amp_acro(times,
    period = 12,
    group = "group"
  ),
  data = testdata_simple_gaussian,
  family = gaussian()
)
object
#> 
#>  Conditional Model 
#> 
#>  Raw formula: 
#> Y ~ group + group:main_rrr1 + group:main_sss1 
#> 
#>  Raw Coefficients: 
#>                  Estimate
#> (Intercept)       4.96475
#> group1           -0.98130
#> group0:main_rrr1  1.04667
#> group1:main_rrr1  0.88812
#> group0:main_sss1  1.68266
#> group1:main_sss1  0.47976
#> 
#>  Transformed Coefficients: 
#>               Estimate
#> (Intercept)    4.96475
#> [group=1]     -0.98130
#> [group=0]:amp  1.98163
#> [group=1]:amp  1.00942
#> [group=0]:acr  1.01433
#> [group=1]:acr  0.49528

This is the same dataset used in the previous example, but note the following differences:

  • The MESOR estimate for the reference group (group = 0) is given by (Intercept) = 4.96476

  • The estimate for the difference between the MESOR of the reference group (group = 0) and the treatment group (group = 1) is given by [group=1] = -0.98129. As such, the estimate for the MESOR of group = 1 is 3.98347.

  • The estimates for amplitude and acrophase are slightly different to the previous example because there is no longer a shared MESOR.

Plotting this model and comparing to the previous model which used the same dataset, one can appreciate the importance of specifying the formula correctly in order to gain the most accurate model.

autoplot(object)

We may also be interested in estimating the MESOR for the two groups separately, rather than the difference between groups. To achieve this, we can remove the intercept term by using 0 +.

cglmm(
  Y ~ 0 + group + amp_acro(times,
    period = 12,
    group = "group"
  ),
  data = testdata_simple,
  family = poisson()
)
#> 
#>  Conditional Model 
#> 
#>  Raw formula: 
#> Y ~ group + group:main_rrr1 + group:main_sss1 - 1 
#> 
#>  Raw Coefficients: 
#>                  Estimate
#> group0            4.99845
#> group1            3.99631
#> group0:main_rrr1  1.08228
#> group1:main_rrr1  0.87665
#> group0:main_sss1  1.68235
#> group1:main_sss1  0.48195
#> 
#>  Transformed Coefficients: 
#>               Estimate
#> [group=0]      4.99845
#> [group=1]      3.99631
#> [group=0]:amp  2.00041
#> [group=1]:amp  1.00040
#> [group=0]:acr  0.99913
#> [group=1]:acr  0.50266

Specifying more complicated models using the amp_acro() function

The amp_acro() function controls the cosinor components of model (specifically, this affects just the fixed-effects part). It provides the user with the ability to specify grouping structures, the period of the rhythm, and the number of components. There are several arguments that the user must specify:

  • group is the name of the grouping variable in the dataset. This can be a string or an object

  • time_col is the name of the time column in the dataset. This can be a string or an object

  • n_components is the number of components.

If the user wishes to fit a multicomponent cosinor model, they can specify the number of components using the n_components variable. The value of n_components will need to match the length of the group and period arguments as these will be combined for each component.

For example:

testdata_two_components <- simulate_cosinor(
  1000,
  n_period = 10,
  mesor = 7,
  amp = c(0.1, 0.4),
  acro = c(1, 1.5),
  beta.mesor = 4.4,
  beta.amp = c(2, 1),
  beta.acro = c(1, -1.5),
  family = "poisson",
  period = c(12, 6),
  n_components = 2,
  beta.group = TRUE
)
cglmm(
  Y ~ group + amp_acro(
    time_col = times,
    n_components = 2,
    period = c(12, 6),
    group = c("group", "group")
  ),
  data = testdata_two_components,
  family = poisson()
)
#> 
#>  Conditional Model 
#> 
#>  Raw formula: 
#> Y ~ group + group:main_rrr1 + group:main_sss1 + group:main_rrr2 +      group:main_sss2 
#> 
#>  Raw Coefficients: 
#>                  Estimate
#> (Intercept)       7.00043
#> group1           -2.60739
#> group0:main_rrr1  0.05665
#> group1:main_rrr1  1.08270
#> group0:main_sss1  0.08378
#> group1:main_sss1  1.68926
#> group0:main_rrr2  0.02884
#> group1:main_rrr2  0.07367
#> group0:main_sss2  0.39671
#> group1:main_sss2 -0.99891
#> 
#>  Transformed Coefficients: 
#>                Estimate
#> (Intercept)     7.00043
#> [group=1]      -2.60739
#> [group=0]:amp1  0.10113
#> [group=1]:amp1  2.00645
#> [group=0]:amp2  0.39776
#> [group=1]:amp2  1.00162
#> [group=0]:acr1  0.97624
#> [group=1]:acr1  1.00082
#> [group=0]:acr2  1.49824
#> [group=1]:acr2 -1.49718

In the output, the suffix on the estimates for amplitude and acrophase represents its component:

  • [group=0]:amp1 = 0.10113 represents the estimate for amplitude of group 0 for the first component

  • [group=1]:amp1 = 2.00645 represents the estimate for amplitude of group 1 for the first component

  • [group=0]:amp2 = 0.39776 represents the estimate for amplitude of group 0 for the second component

  • [group=1]:amp2 = 1.00162 represents the estimate for amplitude of group 1 for the second component

  • Similarly for acrophase estimates

If a multicomponent model has one component that is grouped with other components that aren’t, the vector input for group must still be the same length as n_components but have the non-grouped components represented as group = NA.

For example, if we wanted only the first component to have a grouped component, we would specify the group argument as group = c("group", NA)).

For a detailed explanation of how to specify multi-component models, see multiple-components

Dispersion and zero-inflation model specification

The cglmm() function allows users to specify formulas for dispersion and zero-inflation models. These formulas are independent of the main formula specification:

testdata_disp_zi <- simulate_cosinor(1000,
  n_period = 6,
  mesor = 7,
  amp = c(0.1, 0.4, 0.5),
  acro = c(1, 1.5, 0.1),
  beta.mesor = 4.4,
  beta.amp = c(2, 1, 0.4),
  beta.acro = c(1, -1.5, -1),
  family = "gaussian",
  period = c(12, 6, 8),
  n_components = 3
)
object_disp_zi <- cglmm(
  Y ~ group + amp_acro(times,
    n_components = 3,
    period = c(12, 6, 8),
    group = "group"
  ),
  data = testdata_disp_zi, family = gaussian(),
  dispformula = ~ group + amp_acro(times,
    n_components = 2,
    group = "group",
    period = c(12, 6)
  ),
  ziformula = ~ group + amp_acro(times,
    n_components = 3,
    group = "group",
    period = c(7, 8, 2)
  )
)

object_disp_zi
#> 
#>  Conditional Model 
#> 
#>  Raw formula: 
#> Y ~ group + group:main_rrr1 + group:main_sss1 + group:main_rrr2 +      group:main_sss2 + group:main_rrr3 + group:main_sss3 
#> 
#>  Raw Coefficients: 
#>                  Estimate
#> (Intercept)       7.02767
#> group1           -2.57931
#> group0:main_rrr1  0.06685
#> group1:main_rrr1  1.05728
#> group0:main_sss1  0.03885
#> group1:main_sss1  1.63436
#> group0:main_rrr2  0.05475
#> group1:main_rrr2  0.12098
#> group0:main_sss2  0.38304
#> group1:main_sss2 -0.99745
#> group0:main_rrr3  0.47278
#> group1:main_rrr3  0.24164
#> group0:main_sss3  0.04805
#> group1:main_sss3 -0.40999
#> 
#>  Transformed Coefficients: 
#>                Estimate
#> (Intercept)     7.02767
#> [group=1]      -2.57931
#> [group=0]:amp1  0.07732
#> [group=1]:amp1  1.94653
#> [group=0]:amp2  0.38693
#> [group=1]:amp2  1.00476
#> [group=0]:amp3  0.47522
#> [group=1]:amp3  0.47590
#> [group=0]:acr1  0.52649
#> [group=1]:acr1  0.99660
#> [group=0]:acr2  1.42883
#> [group=1]:acr2 -1.45010
#> [group=0]:acr3  0.10129
#> [group=1]:acr3 -1.03823
#> 
#> ***********************
#> 
#>  Dispersion Model 
#> 
#>  Raw  Formula: 
#> ~group + group:disp_rrr1 + group:disp_sss1 + group:disp_rrr2 +      group:disp_sss2 
#> 
#>  Raw  Coefficients: 
#>                  Estimate
#> (Intercept)      -0.02030
#> group1            0.03264
#> group0:disp_rrr1 -0.01403
#> group1:disp_rrr1  0.02934
#> group0:disp_sss1 -0.07156
#> group1:disp_sss1  0.02445
#> group0:disp_rrr2 -0.03191
#> group1:disp_rrr2 -0.00472
#> group0:disp_sss2 -0.01580
#> group1:disp_sss2  0.03917
#> 
#>  Transformed  Coefficients: 
#>                Estimate
#> (Intercept)    -0.02030
#> [group=1]       0.03264
#> [group=0]:amp1  0.07292
#> [group=1]:amp1  0.03819
#> [group=0]:amp2  0.03561
#> [group=1]:amp2  0.03946
#> [group=0]:acr1 -1.76435
#> [group=1]:acr1  0.69465
#> [group=0]:acr2 -2.68184
#> [group=1]:acr2  1.69060
#> 
#> ***********************
#> 
#>  Zero-Inflation Model 
#> 
#>  Raw  Formula: 
#> ~group + group:zi_rrr1 + group:zi_sss1 + group:zi_rrr2 + group:zi_sss2 +      group:zi_rrr3 + group:zi_sss3 
#> 
#>  Raw  Coefficients: 
#>                 Estimate
#> (Intercept)    -22.17517
#> group1          -0.40841
#> group0:zi_rrr1  -0.02056
#> group1:zi_rrr1   0.00891
#> group0:zi_sss1  -0.00035
#> group1:zi_sss1  -0.00207
#> group0:zi_rrr2  -0.01454
#> group1:zi_rrr2   0.00515
#> group0:zi_sss2  -0.00964
#> group1:zi_sss2   0.00477
#> group0:zi_rrr3   0.01877
#> group1:zi_rrr3  -0.00928
#> group0:zi_sss3  -0.00996
#> group1:zi_sss3   0.00491
#> 
#>  Transformed  Coefficients: 
#>                 Estimate
#> (Intercept)    -22.17517
#> [group=1]       -0.40841
#> [group=0]:amp1   0.02056
#> [group=1]:amp1   0.00915
#> [group=0]:amp2   0.01745
#> [group=1]:amp2   0.00702
#> [group=0]:amp3   0.02125
#> [group=1]:amp3   0.01050
#> [group=0]:acr1  -3.12477
#> [group=1]:acr1  -0.22870
#> [group=0]:acr2  -2.55614
#> [group=1]:acr2   0.74687
#> [group=0]:acr3  -0.48795
#> [group=1]:acr3   2.65451

The output provides estimates for conditional model (default model), the dispersion model, and also the zero-inflation model. By default, dispformula = ~1, and ziformula = ~0 which means these additional models will not be generated in the output.

Note that in the example above, the value for the periods and the number of components in the dispersion and zero-inflation formulas were chosen arbitrarily and purely for demonstration.

Using summary(cglmm)

The summary() method for cglmm objects provides a more detailed summary of the model and its parameter estimates and uncertainty. It outputs the estimates, standard errors, confidence intervals, and p-values for both the raw model parameters and the transformed parameters. The summary statistics do not represent a comparison between any groups for the cosinor components - that is the role of the test_cosinor() function.

Here is an example of how to use summary():

object <- cglmm(
  Y ~ group + amp_acro(times,
    period = 12,
    group = "group"
  ),
  data = testdata_simple,
  family = poisson()
)
summary(object)
#> 
#>  Conditional Model 
#> Raw model coefficients:
#>                      estimate standard.error     lower.CI upper.CI    p.value
#> (Intercept)       4.998454142    0.003463730  4.991665356  5.00524 < 2.22e-16
#> group1           -1.002150001    0.005937109 -1.013786521 -0.99051 < 2.22e-16
#> group0:main_rrr1  1.082281784    0.003347565  1.075720677  1.08884 < 2.22e-16
#> group1:main_rrr1  0.876651963    0.006198710  0.864502714  0.88880 < 2.22e-16
#> group0:main_sss1  1.682350718    0.003919418  1.674668800  1.69003 < 2.22e-16
#> group1:main_sss1  0.481951763    0.005936670  0.470316104  0.49359 < 2.22e-16
#>                     
#> (Intercept)      ***
#> group1           ***
#> group0:main_rrr1 ***
#> group1:main_rrr1 ***
#> group0:main_sss1 ***
#> group1:main_sss1 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Transformed coefficients:
#>                    estimate standard.error     lower.CI upper.CI    p.value    
#> (Intercept)     4.998454142    0.003463730  4.991665356  5.00524 < 2.22e-16 ***
#> [group=1]      -1.002150001    0.005937109 -1.013786521 -0.99051 < 2.22e-16 ***
#> [group=0]:amp1  2.000409408    0.004275553  1.992029478  2.00879 < 2.22e-16 ***
#> [group=1]:amp1  1.000398004    0.006379631  0.987894156  1.01290 < 2.22e-16 ***
#> [group=0]:acr1  0.999134804    0.001439122  0.996314177  1.00196 < 2.22e-16 ***
#> [group=1]:acr1  0.502662067    0.005739524  0.491412807  0.51391 < 2.22e-16 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

The summary statistics for dispersion and zero-inflation models will also be provided by the summary() function, if the original cglmm object being analyzed contains them. The following demonstration uses the model specified in the Dispersion and Zero-inflation model specification section of this vignette:

summary(object_disp_zi)
#> 
#>  Conditional Model 
#> Raw model coefficients:
#>                     estimate standard.error    lower.CI upper.CI    p.value    
#> (Intercept)       7.02766964     0.03111193  6.96669139  7.08865 < 2.22e-16 ***
#> group1           -2.57931465     0.04468774 -2.66690101 -2.49173 < 2.22e-16 ***
#> group0:main_rrr1  0.06684655     0.04359068 -0.01858961  0.15228  0.1251513    
#> group1:main_rrr1  1.05728396     0.04553036  0.96804609  1.14652 < 2.22e-16 ***
#> group0:main_sss1  0.03885210     0.04448736 -0.04834152  0.12605  0.3824838    
#> group1:main_sss1  1.63435875     0.04529405  1.54558405  1.72313 < 2.22e-16 ***
#> group0:main_rrr2  0.05474511     0.04413112 -0.03175030  0.14124  0.2147868    
#> group1:main_rrr2  0.12098111     0.04567129  0.03146703  0.21050  0.0080741 ** 
#> group0:main_sss2  0.38303789     0.04397870  0.29684121  0.46923 < 2.22e-16 ***
#> group1:main_sss2 -0.99744915     0.04528668 -1.08620941 -0.90869 < 2.22e-16 ***
#> group0:main_rrr3  0.47278143     0.04411340  0.38632076  0.55924 < 2.22e-16 ***
#> group1:main_rrr3  0.24163617     0.04608626  0.15130875  0.33196 1.5788e-07 ***
#> group0:main_sss3  0.04805021     0.04365437 -0.03751079  0.13361  0.2710288    
#> group1:main_sss3 -0.40999188     0.04525978 -0.49869942 -0.32128 < 2.22e-16 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Transformed coefficients:
#>                    estimate standard.error     lower.CI upper.CI  p.value    
#> (Intercept)     7.027669645    0.031111927  6.966691388  7.08865  < 2e-16 ***
#> [group=1]      -2.579314651    0.044687741 -2.666901013 -2.49173  < 2e-16 ***
#> [group=0]:amp1  0.077317183    0.043247861 -0.007447066  0.16208 0.073813 .  
#> [group=1]:amp1  1.946529707    0.045840263  1.856684442  2.03637  < 2e-16 ***
#> [group=0]:amp2  0.386930291    0.044006991  0.300678173  0.47318  < 2e-16 ***
#> [group=1]:amp2  1.004759292    0.045266986  0.916037629  1.09348  < 2e-16 ***
#> [group=0]:amp3  0.475216904    0.043933231  0.389109354  0.56132  < 2e-16 ***
#> [group=1]:amp3  0.475900598    0.046078420  0.385588555  0.56621  < 2e-16 ***
#> [group=0]:acr1  0.526491126    0.579699029 -0.609698093  1.66268 0.363765    
#> [group=1]:acr1  0.996596002    0.023107986  0.951305183  1.04189  < 2e-16 ***
#> [group=0]:acr2  1.428834267    0.113981553  1.205434528  1.65223  < 2e-16 ***
#> [group=1]:acr2 -1.450095413    0.045474382 -1.539223564 -1.36097  < 2e-16 ***
#> [group=0]:acr3  0.101285259    0.092243539 -0.079508754  0.28208 0.272196    
#> [group=1]:acr3 -1.038231027    0.095120208 -1.224663208 -0.85180  < 2e-16 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> ***********************
#> 
#>  Dispersion Model 
#> Raw model coefficients:
#>                      estimate standard.error     lower.CI upper.CI  p.value  
#> (Intercept)      -0.020302766    0.022368339 -0.064143906  0.02354 0.364060  
#> group1            0.032635531    0.031633742 -0.029365464  0.09464 0.302228  
#> group0:disp_rrr1 -0.014026132    0.031822707 -0.076397492  0.04835 0.659388  
#> group1:disp_rrr1  0.029344061    0.032209250 -0.033784910  0.09247 0.362272  
#> group0:disp_sss1 -0.071558263    0.031515936 -0.133328362 -0.00979 0.023175 *
#> group1:disp_sss1  0.024448966    0.031623926 -0.037532789  0.08643 0.439454  
#> group0:disp_rrr2 -0.031914888    0.031729594 -0.094103750  0.03027 0.314493  
#> group1:disp_rrr2 -0.004715528    0.031913935 -0.067265691  0.05783 0.882534  
#> group0:disp_sss2 -0.015802229    0.031686011 -0.077905670  0.04630 0.617981  
#> group1:disp_sss2  0.039172356    0.031841954 -0.023236727  0.10158 0.218618  
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Transformed coefficients:
#>                   estimate standard.error    lower.CI upper.CI    p.value    
#> (Intercept)    -0.02030277     0.02236834 -0.06414391  0.02354  0.3640598    
#> [group=1]       0.03263553     0.03163374 -0.02936546  0.09464  0.3022275    
#> [group=0]:amp1  0.07291994     0.03144086  0.01129698  0.13454  0.0203803 *  
#> [group=1]:amp1  0.03819458     0.03174754 -0.02402946  0.10042  0.2289485    
#> [group=0]:amp2  0.03561279     0.03153706 -0.02619871  0.09742  0.2587982    
#> [group=1]:amp2  0.03945516     0.03184224 -0.02295448  0.10186  0.2153150    
#> [group=0]:acr1 -1.76435238     0.43742331 -2.62168631 -0.90702 5.4949e-05 ***
#> [group=1]:acr1  0.69464941     0.84010382 -0.95192382  2.34122  0.4083156    
#> [group=0]:acr2 -2.68184332     0.89511805 -4.43624246 -0.92744  0.0027348 ** 
#> [group=1]:acr2  1.69059883     0.80885870  0.10526491  3.27593  0.0366085 *  
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> ***********************
#> 
#>  Zero-Inflation Model 
#> Raw model coefficients:
#>                     estimate standard.error      lower.CI upper.CI p.value
#> (Intercept)    -2.217517e+01   2.069477e+03 -4.078276e+03 4033.926 0.99145
#> group1         -4.084060e-01   3.276942e+03 -6.423096e+03 6422.279 0.99990
#> group0:zi_rrr1 -2.055689e-02   2.969238e+03 -5.819620e+03 5819.579 0.99999
#> group1:zi_rrr1  8.907702e-03   3.640629e+03 -7.135493e+03 7135.511 1.00000
#> group0:zi_sss1 -3.457992e-04   3.049855e+03 -5.977607e+03 5977.606 1.00000
#> group1:zi_sss1 -2.073432e-03   3.738169e+03 -7.326678e+03 7326.674 1.00000
#> group0:zi_rrr2 -1.454066e-02   3.036183e+03 -5.950825e+03 5950.795 1.00000
#> group1:zi_rrr2  5.153271e-03   3.720527e+03 -7.292094e+03 7292.104 1.00000
#> group0:zi_sss2 -9.640336e-03   2.982571e+03 -5.845742e+03 5845.722 1.00000
#> group1:zi_sss2  4.770722e-03   3.656322e+03 -7.166254e+03 7166.263 1.00000
#> group0:zi_rrr3  1.877380e-02   2.968848e+03 -5.818816e+03 5818.853 0.99999
#> group1:zi_rrr3 -9.279043e-03   3.638615e+03 -7.131564e+03 7131.546 1.00000
#> group0:zi_sss3 -9.964386e-03   2.887912e+03 -5.660213e+03 5660.193 1.00000
#> group1:zi_sss3  4.914652e-03   3.540103e+03 -6.938469e+03 6938.479 1.00000
#> 
#> Transformed coefficients:
#>                     estimate standard.error      lower.CI    upper.CI p.value
#> (Intercept)    -2.217517e+01   2.069477e+03 -4.078276e+03    4033.926 0.99145
#> [group=1]      -4.084060e-01   3.276942e+03 -6.423096e+03    6422.279 0.99990
#> [group=0]:amp1  2.055980e-02   2.967313e+03 -5.815807e+03    5815.848 0.99999
#> [group=1]:amp1  9.145834e-03   3.678115e+03 -7.208963e+03    7208.981 1.00000
#> [group=0]:amp2  1.744612e-02   2.984175e+03 -5.848858e+03    5848.893 1.00000
#> [group=1]:amp2  7.022534e-03   3.645031e+03 -7.144123e+03    7144.137 1.00000
#> [group=0]:amp3  2.125428e-02   2.957056e+03 -5.795703e+03    5795.745 0.99999
#> [group=1]:amp3  1.050021e-02   3.621989e+03 -7.098958e+03    7098.979 1.00000
#> [group=0]:acr1 -3.124773e+00   1.484318e+05 -2.909241e+05  290917.844 0.99998
#> [group=1]:acr1 -2.286961e-01   4.046970e+05 -7.931919e+05  793191.398 1.00000
#> [group=0]:acr2 -2.556139e+00   1.739417e+05 -3.409220e+05  340916.868 0.99999
#> [group=1]:acr2  7.468694e-01   5.313736e+05 -1.041472e+06 1041473.840 1.00000
#> [group=0]:acr3 -4.879520e-01   1.364424e+05 -2.674226e+05  267421.616 1.00000
#> [group=1]:acr3  2.654507e+00   3.387657e+05 -6.639659e+05  663971.205 0.99999

Note that this dataset was not simulated with consideration of dispersion or zero-inflation characteristics, hence the lack of significant P-values in the model summary for the dispersion and zero-inflation models.

Assessing residual diagnostics of cglmm regression models using DHARMa

{DHARMa} is an R package used to assess residual diagnostics of regression models fit using {glmmTMB} (which is what is used by cglmm()).

For example, we can apply the functions from DHARMa on the glmmTMB model within by accessing it with $fit.

library(DHARMa)
#> This is DHARMa 0.4.7. For overview type '?DHARMa'. For recent changes, type news(package = 'DHARMa')
plotResiduals(simulateResiduals(object$fit))