ICC {samplesize4surveys} | R Documentation |
Intraclass Correlation Coefficient
Description
This function computes the intraclass correlation coefficient.
Usage
ICC(y, cl)
Arguments
y |
The variable of interest. |
cl |
The variable indicating the membership of each element to a specific cluster. |
Details
The intraclass correlation coefficient is defined as:
\rho = 1- \frac{m}{m-1} \frac{WSS}{TSS}
Where m
is the average sample sie of units selected inside each sampled cluster.
Value
The total sum of squares (TSS), the between sum of squqres (BSS), the within sum of squares (WSS) and the intraclass correlation coefficient.
Author(s)
Hugo Andres Gutierrez Rojas <hagutierrezro at gmail.com>
References
Gutierrez, H. A. (2009), Estrategias de muestreo: Diseno de encuestas y estimacion de parametros. Editorial Universidad Santo Tomas
See Also
Examples
##########################################
# Almost same mean in each cluster #
# #
# - Heterogeneity within clusters #
# - Homogeinity between clusters #
##########################################
# Population size
N <- 100000
# Number of clusters in the population
NI <- 1000
# Number of elements per cluster
N/NI
# The variable of interest
y <- c(1:N)
# The clustering factor
cl <- rep(1:NI, length.out=N)
table(cl)
tapply(y, cl, FUN=mean)
boxplot(y~cl)
rho = ICC(y,cl)$ICC
rho
##########################################
# Very different means per cluster #
# #
# - Heterogeneity between clusters #
# - Homogeinity within clusters #
##########################################
# Population size
N <- 100000
# Number of clusters in the population
NI <- 1000
# Number of elements per cluster
N/NI
# The variable of interest
y <- c(1:N)
# The clustering factor
cl <- kronecker(c(1:NI),rep(1,N/NI))
table(cl)
tapply(y, cl, FUN=mean)
boxplot(y~cl)
rho = ICC(y,cl)$ICC
rho
############################
# Example 1 with Lucy data #
############################
data(Lucy)
attach(Lucy)
N <- nrow(Lucy)
y <- Income
cl <- Zone
ICC(y,cl)
############################
# Example 2 with Lucy data #
############################
data(Lucy)
attach(Lucy)
N <- nrow(Lucy)
y <- as.double(SPAM)
cl <- Zone
ICC(y,cl)
[Package samplesize4surveys version 4.1.1 Index]