add.point.est: Adds point estimates to samples.

View source: R/add.point.est.r

add.point.estR Documentation

Adds point estimates to samples.

Description

This function calculates point estimates of population mean, total or proportion from an object of class 'sample' or 'samples.population' and adds it to the sample in a column named "point.est".

Usage

  add.point.est(dat,type="ybar",cond=NULL)

Arguments

dat

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

type

Type of point 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.ratiostratified 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.regrstratified 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.diffrstratified 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

cond

Condition to use when calculation proportions. Character of form "<logical operator><value>", where <value> is a valid value for the response variable (y) and <logical operator> is one of the following:

  • "<"if you want the proportion of response values less than <value>

  • ">"if you want the proportion of response values greater than <value>

  • "<="if you want the proportion of response values less than or equal to <value>

  • ">="if you want the proportion of response values greater than or equal to <value>

  • "=="if you want the proportion of response values equal to <value>

  • "!="if you want the proportion of response values not equal to <value>

Details

Returns object identical to 'dat' but with a new element called "point.est" containing the point estimate(s) of the appropriate type.

Value

Returns data frame identical to 'dat' but with a new column called "point.est" containing the point estimate(s) of the appropriate type.

See Also

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

Examples

  data(barnett) # get barnett data
  
  # All samples total weight of class from srs:
  samp.dbn<-take.sample(barnett,y.name="weight",n=23,take.all=TRUE)
  # estimate total
  samp.dbn<-add.point.est(samp.dbn,type="ybar.tot")
  
  # proportion of class with weight more than 15, from srs:
  samp.dbn<-take.sample(barnett,y.name="weight",n=23,take.all=TRUE)
  # estimate total
  samp.dbn<-add.point.est(samp.dbn,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.dbn<-take.sample(strat.barnett,y.name="height",type="strat",n=c(2,9,7,3),ta
                            ke.all=TRUE)
  # estimate mean height using stratified estimator
  samp.dbn<-add.point.est(samp.dbn,type="strat.mean")
  
  # Cluster mean
  # Define 5 clusters based on weight:
  clust.barnett<-define.subunit(barnett,aux.name="weight",
                                breaks=c(0,10,15,20,25,30,40),type="clust")
  # take cluster sample of size 3
  
    samp.dbn<-take.sample(clust.barnett,y.name="height",type="clust",m=3,take.all=TR
                            UE)
  # estimate mean height using cluster estimator
  samp.dbn<-add.point.est(samp.dbn,type="clust.mean")
  
  # Ratio estimator
  # take srs of size 6, with weight as auxiliary variable:
  
    samp.dbn<-take.sample(barnett,y.name="height",aux.name="weight",type="srs",n=23,
                            take.all=TRUE)
  # estimate mean height using cluster estimator
  samp.dbn<-add.point.est(samp.dbn,type="ratio.mean")
  

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