Examples of assessment of agreement with count data"

  collapse = TRUE,
  comment = "#>", fig.width=6, fig.height=4


This vignette is devoted to show the application of iccCounts package to assess the repeatability and concordance with some examples where the outcomes are counts. In both analyses (repeatability and concordance), repeated measures are taken on a sample of subjects and the agreement among the repeated measures from the same subjects is assessed. In the repeatability analysis the repeated measures are interchangeable (replicates) whilst in the concordance analysis they are structured (not interchangeable) because they were obtained by different methods.

The index used to assess the agreement is the intraclass correlation coefficient (ICC) (Fleiss, 1986) which in the case of the concordance analysis is equivalent to the concordance correlation coefficient (Lin, 1989; Carrasco and Jover, 2003).

In the case of count data, the ICC is estimated by means a generalized linear mixed model (GLMM) with a subject's (cluster) random effect distributed as a Normal distribution with 0 mean and variance $\sigma_b^2$. The expression of the ICC depends on the assumed within-subjects distribution (Carrasco, 2010). The GLMM is estimated using the glmmTMB package (Brooks et al., 2017).

As a first analysis, the Poisson distribution will be considered. However, the validity of the ICC estimate is closely linked to the validity of the model. Thus, a goodness-of-fit (GOF) analysis of the model has to be carried out. The GOF analysis will involve the computation of randomized quantile residuals (RQR) (Dunn, 1996; Feng et al. 2020). The RQR from the original data will be compared to those obtained by simulation under the fitted model. The number of simulation by default is 100, but it can be increased to get more precision. Thus, simulated data are generated using the assumed model and their sample estimates. The model is refitted at each simulation and the RQR computed.

Using the original and simulated RQR the GOF will involve:

Example 1. CD34+ count cell data

A new method of flow cytometry for counting CD34+ cells is compared to the readings obtained by the standard approach (Fornas et al., 2000). Both were applied to a sample of 20 subjects. In the dataset, the new and standard methods are coded as 1 and 3 respectively.

Load the package:


Let's estimate the ICC assuming the within-subjects pdf is Poisson. The function icc_counts is a wrapper that will execute the analysis. The function will give as a result an object of class iccc that is a list with the following components:

Additionally, because we are facing a concordance analysis, the name of the method variable has to be provided using the met argument along specifying the type of analysis in the type argument.


The estimate of the ICC is:


and the variance components estimates are:


where mu stands for the overall expectation, BSVar is the variance of the subject's random effect, and BMVar expresses the between-methods variability.

Nevertheless, as it was said before, the validity of the estimates is related to the validity of the model. To check that the function GOF_check is applied on the iccc object. The execution takes some time (46 seconds in i7-CPU at 1.99GHz with 16Gb of RAM). The random seed is fixed to make the result reproducible though differences between simulations should be small with moderate to large number of simulations.


First, let's draw the plot of RQR envelopes.


Several points lie outside of envelopes so the model does not fit appropriately the data.

Let's see if the problem is on the dispersion and/or the number of zeros.


The dispersion of the RQR from the original sample is very much greater than that from the simulated RQR. So that, the model assuming a Poisson pdf do not fit well the actual dispersion of data.

On the other hand, there is no problem with the number of zeros.


Let's try to fit the model with Negative Binomial pdf to afford a larger dispersion. The family "nbinom1" involves an additive extradispersion, $Var\left(y_i\right)=\mu_i\left(1+r\right)$, while "nbinom2" family considers a proportional extradispersion, $Var\left(y_i\right)=\mu_i\left(1+r\mu_i\right)$. To check which model fits better the data the generic function AIC is applied to the glmmTMB object.

AF_NB1<-icc_counts(AF,y="y",id="id",met="met",type="con", fam="nbinom1")
AF_NB2<-icc_counts(AF,y="y",id="id",met="met",type="con", fam="nbinom2")

The Negative Binomial with proportional extradispersion has a slightly lower AIC. Let's check the goodness of for for this model.


In the The plot of RQR envelopes, all the original RQR lie within the envelopes, so the model fits correctly the data.


The dispersion of the original RQR is compatible with those simulated RQR, so that the dispersion estimated by the model is now correct.


Finally, the ICC estimate using this is:


and the variance components


Example 2. Tick counts data

In this study, the repeatability of line transects survey method to estimate tick abundance was assessed (Kjellander et al., 2021). With this aim, sampling was performed by two parallel transects separated by 1m-2m where the total count of ticks was recorded. In this analysis, every pair of transects are considered as replicates of a common transect.

The ICC estimate assuming a Poisson distribution for the within-subjects variability is:


When checking the GOF, if the plot function is applied with no value in the type argument, the three plots (envelopes, dispersion and zeros) are drawn.


All the RQR are within the envelopes. Furthermore, the dispersion and the zero count are well fitted by the model.


Example 3. Sparrow fledglings paternity

The incidence of extra-pair paternity (EPP) was monitored over 3 breeding seasons in a sparrow colony in Lundy, an island off the southwest coast of England (Schroeder et al., 2012). Here, the repetability of counts of fledglings a male had in every breeding season is assessed.

Let's begin by estimating the ICC assuming a Poisson distribution for the within-subjects variability,


Next, let's check the GOF.


The envelopes plot show some residuals that lie outside the envelopes.


The dispersion is also greater than expected under a Poisson model. Finally, with regard of zero counts,


The number of zeros in the sample is larger than expected under the Poisson assumption.

Thus, it is necessary to try different models that can afford larger dispersion and number of zeros. Let's check if the negative binomial model can be such a model.


In this case, the negative binomial with additive extradispersion fits the data better. Let's check the GOF for this model.


In the envelopes plot, the RQR behave much better than in the Poisson case, However, there still are some points that lie outside the envelopes.


On the other hand, the sample dispersion is compatible to that from the simulated samples.


Finally, there still is an excess of zero counts. Hence, it is necessary to apply a model able to account for a larger number of zeros.

Let's try with the zero inflated Poisson model (ZIP). The ICC and variance components for this model are:


Notice the excess of zeros is about 25% (pi estimate in the output).

Let's proceed by checking the GOF.


All the sample RQR are within the envelopes.

Furthermore, the dispersion and the zero counts are now compatible with the assumed model.



Brooks ME, Kristensen K, van Benthem KJ, Magnusson A, Berg CW, Nielsen A, Skaug HJ, Maechler M, Bolker BM (2017). “glmmTMB Balances Speed and Flexibility Among Packages for Zero-inflated Generalized Linear Mixed Modeling.” The R Journal, 9(2), 378–400. https://journal.r-project.org/archive/2017/RJ-2017-066/index.html.

Carrasco, J. L. and Jover, L. (2003). Estimating the generalized concordance correlation coefficient through variance components. Biometrics 59, 849–858.

Carrasco, J. (2010). A Generalized Concordance Correlation Coefficient Based on the Variance Components Generalized Linear Mixed Models for Overdispersed Count Data. Biometrics, 66(3), 897-904.

Dunn PK, Smyth GK. (1996). Randomized quantile residuals. J Comput Graph Stat. 5(3):236–44.

Feng et al. (2020). A comparison of residual diagnosis tools for diagnosing regression models for count data. BMC Medical Research Methodology 20:175

Fleiss, J.L. (1986). Reliability of measurement. In The Design and Analysis of Clinical Experiments. New York: Wiley.

Fornas, O., Garcia, J., and Petriz, J. (2000). Flow cytometry counting of CD34+ cells in whole blood. Nature Medicine 6, 833–836.

Lin, L. I. K. (1989). A concordance correlation coefficient to evaluate reproducibility. Biometrics 45, 255–268.

Kjellander, P.L., Aronsson, M., Bergvall, U.A. et al. (2021). Validating a common tick survey method: cloth-dragging and line transects. Exp Appl Acarol 83, 131–146.

Schroeder, J., Burke, T., Mannarelli, M. E., Dawson, D. A., & Nakagawa, S. (2012). Maternal effects and heritability of annual productivity. Journal of Evolutionary Biology, 25, 149– 156.

Try the iccCounts package in your browser

Any scripts or data that you put into this service are public.

iccCounts documentation built on July 30, 2021, 5:07 p.m.