Title: | Intraclass Correlation Coefficient for Count Data |
---|---|
Description: | Estimates the intraclass correlation coefficient (ICC) for count data to assess repeatability (intra-methods concordance) and concordance (between-method concordance). In the concordance setting, the ICC is equivalent to the concordance correlation coefficient estimated by variance components. The ICC is estimated using the estimates from generalized linear mixed models. The within-subjects distributions considered are: Poisson; Negative Binomial with additive and proportional extradispersion; Zero-Inflated Poisson; and Zero-Inflated Negative Binomial with additive and proportional extradispersion. The statistical methodology used to estimate the ICC with count data can be found in Carrasco (2010) <doi:10.1111/j.1541-0420.2009.01335.x>. |
Authors: | Josep L. Carrasco <[email protected]> |
Maintainer: | Josep L. Carrasco <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.1.2 |
Built: | 2024-10-29 05:06:37 UTC |
Source: | https://github.com/cran/iccCounts |
A dataset containing CD34+ count cell data obtained by two methods
AF
AF
A data frame with 40 rows and 3 variables:
CD34+ counts
Subject
Method
Fornas, O., Garcia, J., and Petriz, J. (2000). Flow cytometry counting of CD34+ cells in whole blood. Nature Medicine 6, 833–836.
Dispersion test for GLMM
DispersionTest(x)
DispersionTest(x)
x |
An object of class GOF generated by GOF_check function. |
The function prints the dispersion of sample randomized quantile residuals (RQR) and the simulated P-value.
A vector with the sample RQR dispersion and the P-value.
# Poisson model. Repeatability setting. iccpois<-icc_counts(EPP,y="Social",id="id") iccpois.gof<-GOF_check(iccpois) DispersionTest(iccpois.gof)
# Poisson model. Repeatability setting. iccpois<-icc_counts(EPP,y="Social",id="id") iccpois.gof<-GOF_check(iccpois) DispersionTest(iccpois.gof)
A dataset containing the counts of fledglings a male had in every breeding season
EPP
EPP
A data frame with 193 rows and 3 variables:
Fledglings counts
Subject identifier
Breeding season
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.
Assessment of goodness of fit for GLMM
GOF_check(x, nsim = 100, alpha = 0.05)
GOF_check(x, nsim = 100, alpha = 0.05)
x |
An object of clas iccc. |
nsim |
Number of simulations to run. Default is set to 100. |
alpha |
Level of significance |
Randomized quantile residuals are computed for the fitted model. Simulations based on the fitted model are generated and the model is refitted to each simulated dataset. Envelopes for RQR are built as the appropriate quantile (in relation to the level fo significance) of RQR from the refitted models. Additionally, a test for dispersion and zero inflation are carried out by comparing the RQR dispersion and the number of zeros from the original model and data to those from the refitted models and simulated data.
An object of class GOF for which method plot is available. A list with the following components:
plot_env. Plot of RQR envelopes with the original RQR.
plot_var. Plot of the simulated RQR dispersion.
plot_zi. Plot of the count of zeros in the simulated datasets.
res_var. Dispersion of RQR from the original sample.
pval_var. Proportion of simulated RQR dispersion that are greater than the original dispersion that can be interpreted as a simulated P-value to check the goodness of fit on dispersion.
zero_count. Count of zeros in the original sample.
pval_zi. Proportion of simulated zero count that are greater than that of the original sample. It can be interpreted as a simulated P-value to check the hypothesis of zero-inflation.
plot.GOF()
, DispersionTest()
,ZeroTest()
# Poisson model. Repeatability setting. iccpois<-icc_counts(EPP,y="Social",id="id") GOF_check(iccpois) # Zero-inflated Poisson model. Repeatability setting icczip<-icc_counts(EPP,y="Social",id="id",fam="zip") GOF_check(icczip)
# Poisson model. Repeatability setting. iccpois<-icc_counts(EPP,y="Social",id="id") GOF_check(iccpois) # Zero-inflated Poisson model. Repeatability setting icczip<-icc_counts(EPP,y="Social",id="id",fam="zip") GOF_check(icczip)
A dataset containing the counts of ticks in Grimsö area
Grimso
Grimso
A data frame with 520 rows and 3 variables:
Tick counts
Subject identifier
Identifier of repeated measurements
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.
Prints the intraclass correlation coefficient (ICC)
ICC(x, digits = getOption("digits"))
ICC(x, digits = getOption("digits"))
x |
An object of class iccc |
digits |
Number of digits to print |
A vector with the ICC estimate, its standard error and confidence interval.
# Poisson model. Repeatability setting. iccpois<-icc_counts(Grimso,y="Tot",id="TransectID") ICC(iccpois) # Negative Binomial with proportional extra-dispersion. Concordance setting iccnb2<-icc_counts(AF,y="y",id="id",met="met",type="con",fam="nbinom2") ICC(iccnb2) # Zero-inflated Poisson model. Repeatability setting icczip<-icc_counts(EPP,y="Social",id="id",fam="zip") ICC(icczip)
# Poisson model. Repeatability setting. iccpois<-icc_counts(Grimso,y="Tot",id="TransectID") ICC(iccpois) # Negative Binomial with proportional extra-dispersion. Concordance setting iccnb2<-icc_counts(AF,y="y",id="id",met="met",type="con",fam="nbinom2") ICC(iccnb2) # Zero-inflated Poisson model. Repeatability setting icczip<-icc_counts(EPP,y="Social",id="id",fam="zip") ICC(icczip)
Estimates the intraclass correlation coefficient (ICC) for count data
icc_counts( data, y, id, met = NULL, type = c("rep", "con"), fam = c("poisson", "nbinom1", "nbinom2", "zip", "zinb1", "zinb2"), conf = 0.95 )
icc_counts( data, y, id, met = NULL, type = c("rep", "con"), fam = c("poisson", "nbinom1", "nbinom2", "zip", "zinb1", "zinb2"), conf = 0.95 )
data |
A data frame containing at least two columns: outcome and subject identifier. In case of estimating the ICC for concordance setting, a third column with the method identifier will be needed. |
y |
Character string indicating the name of the outcome column in the dataset. |
id |
Character string indicating the name of the subjects column in the dataset. |
met |
Character string indicating the name of the methods column in the dataset. Only needed in the concordance setting. |
type |
Character string. It chooses the setting in which the ICC should be estimated. Valid values are: |
fam |
Character string. The within-subjects pdf to use. Valid options are: |
conf |
Confidence level for the confidence interval estimation. Default value is set to 95%. |
The intraclass correlation coefficient (ICC) is estimated using the variance components of a generalized linear mixed model (GLMM) (Carrasco, 2010).
The GLMM is estimated using the glmmTMB package (Brooks et al. 2017). The ICC standard error is estimated by applying the delta method (Ver Hoef, 2012) using the variance-covariance matrix of parameters involved in the ICC estimate.
The parameters involved in the estimation of the ICC depends on the within-subjects pdf family chosen: the between-subjects variance, the between-methods variability (in case of concordance analysis), and parameters implicated in the within-subjects family chosen. In all cases the output includes the overall expectation identified as mu; the between-subjects variance named as BSVar (log-scale); the between-methods variability (in case of concordance analysis) named as BMVar (log-scale).
In the Negative Binomial pdf with variance linearly increasing with the mean (Hardin and Hilbe, 2007),
and Negative Binomial pdf with variance quadratically increasing with the mean (Hardin and Hilbe, 2007)
the extra-dispersion parameter r is included in the output.
For zero-inflated models, the probability of observing an extra zero is included in the output as pi.
An object of class iccc.The output is a list with the following components:
model. An object of class glmmTMB. The estimated generalized linear mixed model.
ICC. Estimate of the ICC, its standard error and confidence interval.
varcomp. Variance components and parameters related to ICC expression.
Brooks, M. E., Kristensen, K., van Benthem, K. J., Magnusson, A., Berg, C. W., Nielsen, A., Skaug, H. J., Mächler, M. and Bolker, B. M. (2017). glmmTMB balances speed and flexibility among packages for zero-inflated generalized linear mixed modeling. The R Journal, 9(2), 378–400.
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.
W. Hardin and J. Hilbe. (2007). Generalized Linear Models and Extensions. Stata Press.
Ver Hoef, J.M. (2012) Who Invented the Delta Method?, The American Statistician, 66:2, 124-127,
# Poisson model. Repeatability setting. iccpois<-icc_counts(Grimso,y="Tot",id="TransectID") # Negative Binomial with proportional extra-dispersion. Concordance setting iccnb2<-icc_counts(AF,y="y",id="id",met="met",type="con",fam="nbinom2") # Zero-inflated Poisson model. Repeatability setting icczip<-icc_counts(EPP,y="Social",id="id",fam="zip")
# Poisson model. Repeatability setting. iccpois<-icc_counts(Grimso,y="Tot",id="TransectID") # Negative Binomial with proportional extra-dispersion. Concordance setting iccnb2<-icc_counts(AF,y="y",id="id",met="met",type="con",fam="nbinom2") # Zero-inflated Poisson model. Repeatability setting icczip<-icc_counts(EPP,y="Social",id="id",fam="zip")
Draws the Bland-Altman plot. The differences among pair of data from the same subject is represented on y-axis. The mean of data from the same subject is represented on x-axis. Additionally, a bar plot with the proportions of differences can be drawn.
plot_BA(data, y, id, rm = NULL, type = c("BA", "bars"))
plot_BA(data, y, id, rm = NULL, type = c("BA", "bars"))
data |
A data frame containing at least two columns: outcome and subject identifier. |
y |
Character string indicating the name of the outcome column in the data set. |
id |
Character string indicating the name of the subjects column in the data set. |
rm |
Optional. Character string indicating the name of column that stands for the repeated measurements from the same subjects in the dataset. Only needed to identify the differences in the Bland-Altman plot. |
type |
Character. Which plot has to be drawn? Default option is Bland-Altman plot ("BA" option). Alternatively, the bar plot of the proportion of the differences can be created ("bars" option). |
A list with the following components:
plot. An object of class ggplot. The plot generated.
data. An object of class dataframe that contains the data used to generated the plot.
plot_BA(EPP,y="Social",id="id") plot_BA(EPP,y="Social",id="id",rm="Year") plot_BA(EPP,y="Social",id="id",type="bars")
plot_BA(EPP,y="Social",id="id") plot_BA(EPP,y="Social",id="id",rm="Year") plot_BA(EPP,y="Social",id="id",type="bars")
Draws the plots to assess the goodness of fit
## S3 method for class 'GOF' plot(x, type = c("all", "envelope", "dispersion", "zeros"), ...)
## S3 method for class 'GOF' plot(x, type = c("all", "envelope", "dispersion", "zeros"), ...)
x |
An object of class GOF generated by GOF_check function. |
type |
Which plot to draw. Values: all (default); envelope for envelopes of randomized quantile residuals; dispersion for plot to assess the dispersion; zeros for plot to assess the zero inflation. |
... |
Ignore |
# Poisson model. Repeatability setting. iccpois<-icc_counts(EPP,y="Social",id="id") iccpois.gof<-GOF_check(iccpois) plot(iccpois.gof) plot(iccpois.gof,type="envelope") plot(iccpois.gof,type="dispersion") plot(iccpois.gof,type="zeros")
# Poisson model. Repeatability setting. iccpois<-icc_counts(EPP,y="Social",id="id") iccpois.gof<-GOF_check(iccpois) plot(iccpois.gof) plot(iccpois.gof,type="envelope") plot(iccpois.gof,type="dispersion") plot(iccpois.gof,type="zeros")
Prints the GLMM variance components and related parameters to estimate the intraclass correlation coefficient (ICC)
VarComp(x, digits = getOption("digits"))
VarComp(x, digits = getOption("digits"))
x |
An object of class iccc |
digits |
Number of digits to print |
A vector with the variance components and related parameters
# Poisson model. Repeatability setting. iccpois<-icc_counts(Grimso,y="Tot",id="TransectID") VarComp(iccpois) # Negative Binomial with proportional extra-dispersion. Concordance setting iccnb2<-icc_counts(AF,y="y",id="id",met="met",type="con",fam="nbinom2") VarComp(iccnb2) # Zero-inflated Poisson model. Repeatability setting icczip<-icc_counts(EPP,y="Social",id="id",fam="zip") VarComp(icczip)
# Poisson model. Repeatability setting. iccpois<-icc_counts(Grimso,y="Tot",id="TransectID") VarComp(iccpois) # Negative Binomial with proportional extra-dispersion. Concordance setting iccnb2<-icc_counts(AF,y="y",id="id",met="met",type="con",fam="nbinom2") VarComp(iccnb2) # Zero-inflated Poisson model. Repeatability setting icczip<-icc_counts(EPP,y="Social",id="id",fam="zip") VarComp(icczip)
Zero-Inflation test for GLMM
ZeroTest(x)
ZeroTest(x)
x |
An object of class GOF generated by GOF_check function. |
The function prints the count of zeros in the sample and the simulated P-value.
A vector with the zero count and the P-value.
# Poisson model. Repeatability setting. iccpois<-icc_counts(EPP,y="Social",id="id") iccpois.gof<-GOF_check(iccpois) ZeroTest(iccpois.gof) # Zero-inflated Poisson model. Repeatability setting icczip<-icc_counts(EPP,y="Social",id="id",fam="zip") icczip.gof<-GOF_check(icczip) ZeroTest(icczip.gof)
# Poisson model. Repeatability setting. iccpois<-icc_counts(EPP,y="Social",id="id") iccpois.gof<-GOF_check(iccpois) ZeroTest(iccpois.gof) # Zero-inflated Poisson model. Repeatability setting icczip<-icc_counts(EPP,y="Social",id="id",fam="zip") icczip.gof<-GOF_check(icczip) ZeroTest(icczip.gof)