# NOT RUN {
ss2s4m(N=100000, mu=10, sigma=2, conf=0.95, delta=0.03, M=50, rho=0.01)
ss2s4m(N=100000, mu=10, sigma=2, conf=0.95, delta=0.03, M=50, to=40, rho=0.1)
ss2s4m(N=100000, mu=10, sigma=2, conf=0.95, delta=0.03, M=50, to=40, rho=0.2)
ss2s4m(N=100000, mu=10, sigma=2, conf=0.95, delta=0.05, M=50, to=40, rho=0.3)
##########################################
# Almost same mean in each cluster #
# #
# - Heterogeneity within clusters #
# - Homogeinity between clusters #
# #
# Decision rule: #
# * Select a lot of units per cluster #
# * Select a few of clusters #
##########################################
# Population size
N <- 1000000
# Number of clusters in the population
M <- 1000
# Number of elements per cluster
N/M
# The variable of interest
y <- c(1:N)
# The clustering factor
cl <- rep(1:M, length.out=N)
rho = ICC(y,cl)$ICC
rho
ss2s4m(N, mu=mean(y), sigma=sd(y), conf=0.95, delta=0.03, M=M, rho=rho)
##########################################
# Very different means per cluster #
# #
# - Heterogeneity between clusters #
# - Homogeinity within clusters #
# #
# Decision rule: #
# * Select a few of units per cluster #
# * Select a lot of clusters #
##########################################
# Population size
N <- 1000000
# Number of clusters in the population
M <- 1000
# Number of elements per cluster
N/M
# The variable of interest
y <- c(1:N)
# The clustering factor
cl <- kronecker(c(1:M),rep(1,N/M))
rho = ICC(y,cl)$ICC
rho
ss2s4m(N, mu=mean(y), sigma=sd(y), conf=0.95, delta=0.03, M=M, rho=rho)
##########################
# Example with Lucy data #
##########################
data(BigLucy)
attach(BigLucy)
N <- nrow(BigLucy)
P <- prop.table(table(SPAM))[1]
y <- Income
cl <- Segments
rho <- ICC(y,cl)$ICC
M <- length(levels(Segments))
ss2s4m(N, mu=mean(y), sigma=sd(y), conf=0.95, delta=0.03, M=M, rho=rho)
##########################
# Example with Lucy data #
##########################
data(BigLucy)
attach(BigLucy)
N <- nrow(BigLucy)
P <- prop.table(table(SPAM))[1]
y <- Years
cl <- Segments
rho <- ICC(y,cl)$ICC
M <- length(levels(Segments))
ss2s4m(N, mu=mean(y), sigma=sd(y), conf=0.95, delta=0.03, M=M, rho=rho)
# }
Run the code above in your browser using DataLab