model-specification

Oliver Jayasinghe and Rex Parsons

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:

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\pi\) 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.90210
#> group0:main_sss1  1.67745
#> group1:main_sss1  0.48497
#> 
#>  Transformed Coefficients: 
#>               Estimate
#> (Intercept)    4.47411
#> [group=0]:amp  1.96985
#> [group=1]:amp  1.02419
#> [group=0]:acr  1.01896
#> [group=1]:acr  0.49327

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:

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.96476
#> group1           -0.98129
#> 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.96476
#> [group=1]     -0.98129
#> [group=0]:amp  1.98163
#> [group=1]:amp  1.00942
#> [group=0]:acr  1.01433
#> [group=1]:acr  0.49529

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

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:

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.08271
#> 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.97625
#> [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:

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.01421
#> group1           -2.57831
#> group0:main_rrr1  0.07796
#> group1:main_rrr1  1.08697
#> group0:main_sss1  0.11443
#> group1:main_sss1  1.69632
#> group0:main_rrr2  0.08871
#> group1:main_rrr2  0.09434
#> group0:main_sss2  0.44577
#> group1:main_sss2 -1.02200
#> group0:main_rrr3  0.57312
#> group1:main_rrr3  0.17853
#> group0:main_sss3 -0.00725
#> group1:main_sss3 -0.32673
#> 
#>  Transformed Coefficients: 
#>                Estimate
#> (Intercept)     7.01421
#> [group=1]      -2.57831
#> [group=0]:amp1  0.13847
#> [group=1]:amp1  2.01470
#> [group=0]:amp2  0.45451
#> [group=1]:amp2  1.02635
#> [group=0]:amp3  0.57317
#> [group=1]:amp3  0.37232
#> [group=0]:acr1  0.97277
#> [group=1]:acr1  1.00093
#> [group=0]:acr2  1.37437
#> [group=1]:acr2 -1.47875
#> [group=0]:acr3 -0.01265
#> [group=1]:acr3 -1.07072
#> 
#> ***********************
#> 
#>  Dispersion Model 
#> 
#>  Raw  Formula: 
#> ~group + group:disp_rrr1 + group:disp_sss1 + group:disp_rrr2 +      group:disp_sss2 
#> 
#>  Raw  Coefficients: 
#>                  Estimate
#> (Intercept)      -0.03676
#> group1            0.11295
#> group0:disp_rrr1  0.02301
#> group1:disp_rrr1  0.10834
#> group0:disp_sss1 -0.11044
#> group1:disp_sss1 -0.01199
#> group0:disp_rrr2  0.00271
#> group1:disp_rrr2 -0.00304
#> group0:disp_sss2  0.02432
#> group1:disp_sss2  0.00734
#> 
#>  Transformed  Coefficients: 
#>                Estimate
#> (Intercept)    -0.03676
#> [group=1]       0.11295
#> [group=0]:amp1  0.11282
#> [group=1]:amp1  0.10900
#> [group=0]:amp2  0.02447
#> [group=1]:amp2  0.00795
#> [group=0]:acr1 -1.36541
#> [group=1]:acr1 -0.11024
#> [group=0]:acr2  1.45972
#> [group=1]:acr2  1.96369
#> 
#> ***********************
#> 
#>  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.66473
#> group1          -0.40422
#> group0:zi_rrr1  -0.01398
#> group1:zi_rrr1   0.01343
#> group0:zi_sss1  -0.03633
#> group1:zi_sss1   0.03755
#> group0:zi_rrr2   0.01578
#> group1:zi_rrr2  -0.01425
#> group0:zi_sss2  -0.01775
#> group1:zi_sss2   0.01930
#> group0:zi_rrr3  -0.00562
#> group1:zi_rrr3   0.00604
#> group0:zi_sss3  -0.00178
#> group1:zi_sss3   0.00167
#> 
#>  Transformed  Coefficients: 
#>                 Estimate
#> (Intercept)    -22.66473
#> [group=1]       -0.40422
#> [group=0]:amp1   0.03892
#> [group=1]:amp1   0.03988
#> [group=0]:amp2   0.02375
#> [group=1]:amp2   0.02399
#> [group=0]:amp3   0.00590
#> [group=1]:amp3   0.00626
#> [group=0]:acr1  -1.93816
#> [group=1]:acr1   1.22741
#> [group=0]:acr2  -0.84411
#> [group=1]:acr2   2.20682
#> [group=0]:acr3  -2.83427
#> [group=1]:acr3   0.26946

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 analysed 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.014211141    0.031116417  6.953224084  7.07520 < 2.22e-16
#> group1           -2.578312220    0.045299524 -2.667097655 -2.48953 < 2.22e-16
#> group0:main_rrr1  0.077957100    0.043764616 -0.007819970  0.16373 0.07486648
#> group1:main_rrr1  1.086972288    0.046248079  0.996327718  1.17762 < 2.22e-16
#> group0:main_sss1  0.114434603    0.044354815  0.027500763  0.20137 0.00988056
#> group1:main_sss1  1.696318636    0.046944800  1.604308520  1.78833 < 2.22e-16
#> group0:main_rrr2  0.088706053    0.044349903  0.001781840  0.17563 0.04548506
#> group1:main_rrr2  0.094337263    0.046965931  0.002285730  0.18639 0.04457620
#> group0:main_sss2  0.445765675    0.043697644  0.360119866  0.53141 < 2.22e-16
#> group1:main_sss2 -1.022002787    0.046246369 -1.112644004 -0.93136 < 2.22e-16
#> group0:main_rrr3  0.573119340    0.044264219  0.486363064  0.65988 < 2.22e-16
#> group1:main_rrr3  0.178525448    0.046806455  0.086786482  0.27026 0.00013667
#> group0:main_sss3 -0.007249692    0.044073464 -0.093632095  0.07913 0.86934456
#> group1:main_sss3 -0.326731833    0.046648014 -0.418160261 -0.23530 2.4841e-12
#>                     
#> (Intercept)      ***
#> group1           ***
#> group0:main_rrr1 .  
#> group1:main_rrr1 ***
#> group0:main_sss1 ** 
#> group1:main_sss1 ***
#> group0:main_rrr2 *  
#> group1:main_rrr2 *  
#> group0:main_sss2 ***
#> group1:main_sss2 ***
#> group0:main_rrr3 ***
#> group1:main_rrr3 ***
#> group0:main_sss3    
#> group1:main_sss3 ***
#> ---
#> 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.01421114     0.03111642  6.95322408  7.07520 < 2.22e-16 ***
#> [group=1]      -2.57831222     0.04529952 -2.66709765 -2.48953 < 2.22e-16 ***
#> [group=0]:amp1  0.13846511     0.04397570  0.05227432  0.22466  0.0016401 ** 
#> [group=1]:amp1  2.01469741     0.04635784  1.92383773  2.10556 < 2.22e-16 ***
#> [group=0]:amp2  0.45450611     0.04385311  0.36855558  0.54046 < 2.22e-16 ***
#> [group=1]:amp2  1.02634751     0.04618621  0.93582421  1.11687 < 2.22e-16 ***
#> [group=0]:amp3  0.57316519     0.04426686  0.48640374  0.65993 < 2.22e-16 ***
#> [group=1]:amp3  0.37232382     0.04672082  0.28075269  0.46389 1.5981e-15 ***
#> [group=0]:acr1  0.97277420     0.31882068  0.34789715  1.59765  0.0022796 ** 
#> [group=1]:acr1  1.00092780     0.02324737  0.95536379  1.04649 < 2.22e-16 ***
#> [group=0]:acr2  1.37436533     0.09724001  1.18377840  1.56495 < 2.22e-16 ***
#> [group=1]:acr2 -1.47875089     0.04581791 -1.56855234 -1.38895 < 2.22e-16 ***
#> [group=0]:acr3 -0.01264886     0.07689025 -0.16335098  0.13805  0.8693333    
#> [group=1]:acr3 -1.07072318     0.12551917 -1.31673624 -0.82471 < 2.22e-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.036759654    0.044775633 -0.124518283  0.05100 0.411661  
#> group1            0.112946788    0.063324547 -0.011167044  0.23706 0.074486 .
#> group0:disp_rrr1  0.023008307    0.063043760 -0.100555192  0.14657 0.715143  
#> group1:disp_rrr1  0.108335659    0.063221994 -0.015577171  0.23225 0.086607 .
#> group0:disp_sss1 -0.110444247    0.063881792 -0.235650259  0.01476 0.083830 .
#> group1:disp_sss1 -0.011991094    0.063791525 -0.137020186  0.11304 0.850898  
#> group0:disp_rrr2  0.002712229    0.063137599 -0.121035191  0.12646 0.965735  
#> group1:disp_rrr2 -0.003042053    0.063777602 -0.128043856  0.12196 0.961957  
#> group0:disp_sss2  0.024316783    0.063998788 -0.101118536  0.14975 0.703977  
#> group1:disp_sss2  0.007340058    0.063413150 -0.116947432  0.13163 0.907851  
#> ---
#> 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.036759654    0.044775633  -0.124518283  0.05100 0.411661  
#> [group=1]        0.112946788    0.063324547  -0.011167044  0.23706 0.074486 .
#> [group=0]:amp1   0.112815398    0.064164440  -0.012944594  0.23858 0.078710 .
#> [group=1]:amp1   0.108997254    0.063387162  -0.015239300  0.23323 0.085515 .
#> [group=0]:amp2   0.024467572    0.063906046  -0.100785975  0.14972 0.701818  
#> [group=1]:amp2   0.007945473    0.062760735  -0.115063308  0.13095 0.899257  
#> [group=0]:acr1  -1.365408841    0.556272157  -2.455682233 -0.27514 0.014105 *
#> [group=1]:acr1  -0.110235938    0.583752383  -1.254369584  1.03390 0.850218  
#> [group=0]:acr2   1.459718085    2.584296758  -3.605410486  6.52485 0.572182  
#> [group=1]:acr2   1.963693306    8.107726215 -13.927158072 17.85454 0.808625  
#> ---
#> 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.266473e+01   2.644921e+03 -5.206615e+03 5161.286 0.99316
#> group1         -4.042221e-01   4.186432e+03 -8.205661e+03 8204.853 0.99992
#> group0:zi_rrr1 -1.397969e-02   3.797417e+03 -7.442815e+03 7442.787 1.00000
#> group1:zi_rrr1  1.342566e-02   4.648395e+03 -9.110673e+03 9110.699 1.00000
#> group0:zi_sss1 -3.632683e-02   3.813723e+03 -7.474795e+03 7474.723 0.99999
#> group1:zi_sss1  3.754903e-02   4.661630e+03 -9.136589e+03 9136.664 0.99999
#> group0:zi_rrr2  1.577726e-02   3.814210e+03 -7.475698e+03 7475.730 1.00000
#> group1:zi_rrr2 -1.425301e-02   4.660886e+03 -9.135184e+03 9135.155 1.00000
#> group0:zi_sss2 -1.774775e-02   3.797224e+03 -7.442440e+03 7442.404 1.00000
#> group1:zi_sss2  1.930302e-02   4.638294e+03 -9.090871e+03 9090.909 1.00000
#> group0:zi_rrr3 -5.619498e-03   3.842736e+03 -7.531630e+03 7531.619 1.00000
#> group1:zi_rrr3  6.036528e-03   4.695205e+03 -9.202427e+03 9202.439 1.00000
#> group0:zi_sss3 -1.783534e-03   3.652165e+03 -7.158113e+03 7158.109 1.00000
#> group1:zi_sss3  1.667131e-03   4.456883e+03 -8.735328e+03 8735.332 1.00000
#> 
#> Transformed coefficients:
#>                     estimate standard.error      lower.CI    upper.CI p.value
#> (Intercept)    -2.266473e+01   2.644921e+03 -5.206615e+03    5161.286 0.99316
#> [group=1]      -4.042221e-01   4.186432e+03 -8.205661e+03    8204.853 0.99992
#> [group=0]:amp1  3.892390e-02   3.783380e+03 -7.415249e+03    7415.327 0.99999
#> [group=1]:amp1  3.987704e-02   4.630460e+03 -9.075496e+03    9075.576 0.99999
#> [group=0]:amp2  2.374667e-02   3.799393e+03 -7.446650e+03    7446.698 1.00000
#> [group=1]:amp2  2.399490e-02   4.645138e+03 -9.104279e+03    9104.327 1.00000
#> [group=0]:amp3  5.895740e-03   3.802005e+03 -7.451786e+03    7451.798 1.00000
#> [group=1]:amp3  6.262507e-03   4.652232e+03 -9.118201e+03    9118.213 1.00000
#> [group=0]:acr1 -1.938158e+00   9.833671e+04 -1.927383e+05  192734.466 0.99998
#> [group=1]:acr1  1.227411e+00   1.173468e+05 -2.299943e+05  229996.796 0.99999
#> [group=0]:acr2 -8.441074e-01   1.605298e+05 -3.146335e+05  314631.846 1.00000
#> [group=1]:acr2  2.206821e+00   1.939607e+05 -3.801537e+05  380158.117 0.99999
#> [group=0]:acr3 -2.834265e+00   6.266471e+05 -1.228209e+06 1228202.841 1.00000
#> [group=1]:acr3  2.694571e-01   7.188369e+05 -1.408894e+06 1408894.741 1.00000

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.6. For overview type '?DHARMa'. For recent changes, type news(package = 'DHARMa')
plotResiduals(simulateResiduals(object$fit))

plotQQunif(simulateResiduals(object$fit))