ci.est: Calculates confidence interval estimates from samples.

View source: R/ci.est.r

ci.estR Documentation

Calculates confidence interval estimates from samples.

Description

This function calculates confidence interval estimates of population mean, total or proportion from an object of class 'sample' or 'samples.population'.

Usage

                   ci.est(dat,type="ybar",level=0.95)

Arguments

dat

Object of class 'sample' or 'samples.population'.

type

Type of confidence interval estimate. Valid types are

  • ybarsample mean

  • ybar.totsample total

  • ybar.ppnsample proportion

  • strat.meanstratified sample mean

  • strat.totstratified sample totatl

  • strat.ppnstratified sample proportion

  • ratio.meanratio estimate of mean

  • ratio.totratio estimate of toatal

  • ratio.ppnratio estimate of proportion

  • strat.ratio.meanstratified ratio estimate of mean

  • strat.ratio.totstratified ratio estimate of total

  • strat.ratio.ppnstratified ratio estimate of proportion

  • regr.meanregression estimate of mean

  • regr.totregression estimate of total

  • regr.ppnregression estimate of proportion

  • strat.regr.meanstratified regression estimate of mean

  • strat.regr.totstratified regression estimate of total

  • strat.regr.ppnstratified regression estimate of proportion

  • diffr.meandifference estimate of mean

  • diffr.totdifference estimate of total

  • diffr.ppndifference estimate of proportion

  • strat.diffr.meanstratified difference estimate of mean

  • strat.diffr.totstratified difference estimate of total

  • strat.diffr.ppnstratified difference estimate of proportion

  • clust.meancluster estimate of mean from mean of cluster totals

  • clust.totcluster estimate of mean from total of cluster totals

  • clust.ppncluster estimate of proportion from mean of cluster totals

  • clust.r.meancluster ratio estimate of mean

  • clust.r.totcluster ratio estimate of total

  • clust.r.ppncluster ratio estimate of proportion

level

Confidence level; 0.95 (95%) by default.

Details

Returns an approximate confidence interval estimate of the appropriate type, assuming that the statistic has a t-distribution with degrees of freedom equal to sample size.

Value

The function returns a list with elements $ci.lower and $ci.upper, being the lower and upper (100*level) confidence interval bounds from the sample.

See Also

add.ci.est, var.est, add.var.est, point.est, add.point.est

Examples

                   data(barnett) # get barnett data
                   
                   # total weight of class from srs:
                   samp<-take.sample(barnett,y.name="weight",n=6)
                   # estimate total
                   ci.est(samp,type="ybar.tot")
                   
                   # proportion of class with weight more than 15 from srs:
                   samp<-take.sample(barnett,y.name="weight",n=6)
                   # estimate total
                   ci.est(samp,type="ybar.ppn",cond=">15")
                   
                   # Stratified mean
                   # Define 4 strata based on weight, with 10 lb interval widths:
                   strat.barnett<-define.subunit(barnett,aux.name="weight",breaks=c(0,10,20,30,40),type="strat")
                   # take stratified sample
                   samp<-take.sample(strat.barnett,y.name="height",type="strat",n=c(2,5,4,2))
                   # estimate mean height using stratified estimator
                   ci.est(samp,type="strat.mean")
                   
                   # Cluster mean
                   # Define 4 clusters based on weight, with 10 lb interval widths:
                   clust.barnett<-define.subunit(barnett,aux.name="weight",breaks=c(0,10,20,30,40),type="clust")
                   # take cluster sample of size 2
                   samp<-take.sample(clust.barnett,y.name="height",type="clust",m=2)
                   # estimate mean height using cluster estimator
                   ci.est(samp,type="clust.mean")
                   
                   # Ratio estimator
                   # take srs of size 6, with weight as auxiliary variable:
                   samp<-take.sample(clust.barnett,y.name="height",aux.name="weight",type="srs",n=6)
                   # estimate mean height using cluster estimator
                   ci.est(samp,type="ratio.mean")
                   
                   
                   

david-borchers/sampling documentation built on Sept. 17, 2022, 7:54 a.m.