Learn R Programming

iRepro (version 1.2)

intervalICC: Intraclass Correlation Coefficient for Interval-Censored Data

Description

The function calculates intraclass correlation coefficient (ICC) for interval-censored data with two repeated measurements. ICC is estimated by maximum likelihood from model with one fixed and one random effect (both intercepts).

Usage

intervalICC(r1, r2, predefined.classes=FALSE, classes, c.limits, optim.method=1)

Value

An object of class "ICCfit". The object is a list with the components:

icc

maximum likelihood estimate (MLE) of ICC

sigma2.b

MLE of between-class variance \(\sigma^2_b\)

sigma2.w

MLE of within-class variance \(\sigma^2\)

mu

MLE of mean \(\mu\)

loglikelihood

log-likelihood evaluated at MLE parameters

Arguments

r1

data corresponding to the first measurement. If predefined.classes=TRUE (appropriate for grouped data), this is a vector of length \(n\), where each observation is one of the labels given in classes. Otherwise, if predefined.classes=FALSE, r1 is a matrix or a data frame with \(n\) rows and 2 columns, with columns representing lower and upper bounds of censoring intervals (e.g., if \(i\)-th observation lies in the interval [\(a\), \(b\)], then r1[i,]=c(a,b)).

r2

data corresponding to the second measurement. If predefined.classes=TRUE (appropriate for grouped data), this is a vector of length \(n\), where each observation is one of the labels given in classes. Otherwise, if predefined.classes=FALSE, r2 is a matrix or a data frame with \(n\) rows and 2 columns, with columns representing lower and upper bounds of censoring intervals (e.g., if \(i\)-th observation lies in the interval [\(a\), \(b\)], then r2[i,]=c(a,b)).

predefined.classes

logical, indicating whether observations belong to predefined classes (e.g. grouped data in questionnaires) or each observation has its own lower and upper limit (default; FALSE).

classes

a vector with unique labels for the k predefined classes. Required if predefined.classes=TRUE.

c.limits

a matrix or a data frame with k rows and 2 columns, corresponding to lower and upper bounds of censoring intervals for classes. Required if predefined.classes=TRUE.

optim.method

an integer (1 or 2) specifying the optimization method to be used in maximum likelihood estimation (default is 1). Details are given below.

Author

Jelena Kovacic jkovacic@imi.hr

Details

ICC is estimated by maximum likelihood from random effects model $$Y_{ij} = \mu + b_i + e_{ij},$$ where \(b_i\) and \(e_{ij}\) are independent and normally distributed with means 0 and variances \(\sigma^2_b\) and \(\sigma^2\), respectively. If data were uncensored, this would be analogous to

lme(ratings~1, random=~1|id, method="ML", data=observed)

in nlme package, where

observed=as.data.frame(rbind(cbind(r1,1:n), cbind(r2,1:n)))

and colnames(observed)=c("ratings","id"). To maximize log-likelihood, constrOptim from stats package is used (method=BFGS).

Two available optimization methods, specified by optim.method, correspond to two mathematically equivalent expressions for log-likelihood. The option optim.method=1 resulted in slightly more accurate estimates in simulations with grouped data, but optim.method=2 was more numerically stable. See the reference for more details.

References

Kovacic J, Varnai VM. Intraclass correlation coefficient for grouped data. Epidemiology 2014;25(5):769--770.

See Also

summary.ICCfit

Examples

Run this code
# Example with 6 predefined classes (grouped data)
classes <- 1:6
class.limits <- cbind(classes-0.5,classes+0.5)
r1 <- sample(classes,30,replace=TRUE)
r2 <- sample(classes,30,replace=TRUE)

intervalICC(r1,r2,predefined.classes=TRUE,classes,class.limits)

# The same result can be obtained with predefined.classes=FALSE option, 
# although with slower computation time
rtg1 <- matrix(nrow=30,ncol=2)
rtg2 <- matrix(nrow=30,ncol=2)
# when predefined.classes=FALSE, ratings must be given with lower and upper bounds 
# for each observation:
for(i in 1:length(classes)){
  rtg1[r1==classes[i],1] <- class.limits[i,1]
  rtg1[r1==classes[i],2] <- class.limits[i,2]
  rtg2[r2==classes[i],1] <- class.limits[i,1]
  rtg2[r2==classes[i],2] <- class.limits[i,2]
}

intervalICC(rtg1,rtg2,predefined.classes=FALSE)

Run the code above in your browser using DataLab