Learn R Programming

sampling (version 0.1)

balancedcluster: Balanced cluster

Description

Select a balanced sample of clusters and return a matrix that contains the vector of inclusion probabilities and the selected sample.

Usage

balancedcluster(X,m,cluster,selection=1,comment=TRUE,method=1)

Arguments

X
matrix of auxiliary variables on which the sample must be balanced.
m
number of clusters to be selected.
cluster
vector of integers that defines the clusters.
selection
1, selection of the clusters with unequal probabilities proportional to the size, 2, selection of the clusters with equal probabilities.
comment
a comment is written during the execution if comment is equal to TRUE.
method
the used method in the function samplecube.

See Also

samplecube, fastflightcube, landingcube

Examples

Run this code
############
## Example 1
############
# definition of the clusters (3 clusters)
cluster=c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3)
# Matrix of balancing variables
X=cbind(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15))
# Selection of 2 clusters
s=balancedcluster(X,2,cluster,2,TRUE)
# The sample of clusters with the inclusion probabilities of the clusters
s
############
## Example 2
############
data(MU284)
X=cbind(MU284$P75,MU284$CS82,MU284$SS82,MU284$S82,MU284$ME84)
b=balancedcluster(X,10,MU284$CL,1,TRUE)
b

Run the code above in your browser using DataLab