cluster.estimator {samplingR}R Documentation

Parameter estimation for cluster samples

Description

Estimates parameters with optional confidence interval for clustered data of similar cluster size.

Usage

cluster.estimator(
  N,
  data,
  estimator = c("total", "mean", "proportion", "class total"),
  replace = FALSE,
  alpha
)

Arguments

N

Number of clusters for the population

data

Cluster sample

estimator

Estimator to compute. Can be one of "total", "mean", "proportion", "class total". Default is "total".

replace

Whether the sample to be taken can have repeated instances or not.

alpha

Optional value to calculate estimation error and build 1-alpha

Details

This function admits both grouped and non-grouped by cluster data.
Non-grouped data must have interest variable data in the first column and cluster name each individual belongs to in the last column.
Grouped by cluster data must have interest variable data in the first column, cluster size in the second and the cluster name in the last column. Interest values of grouped data must reflect the total value of each cluster.

Value

A list containing different interest values:

Examples

d<-cbind(rnorm(500, 50, 20), rep(c(1:50),10)) #Non-grouped data
sample<-cluster.sample(d, n=10) #Non-grouped sample
sampleg<-aggregate(sample[,1], by=list(Category=sample[,2]), FUN=sum)
sampleg<-cbind(sampleg[,2], rep(10,10), sampleg[,1]) #Same sample but with grouped data
sum(d[,1])
cluster.estimator(N=50, data=sample, estimator="total", alpha=0.05)
cluster.estimator(N=50, data=sampleg, estimator="total", alpha=0.05)

[Package samplingR version 1.0.1 Index]