Learn R Programming

samplingR (version 1.0.1)

srs.estimator: Simple Ramdom Sampling parameter estimation.

Description

Function to make estimations of diferent parameters based on a Simple Random Sample.

Usage

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

Value

A list containing different interest values:

  • estimator

  • variance

  • sampling.error

  • estimation.error

  • confint

Arguments

N

Number of instances of the data set.

data

Sample of the data. It must only contain a single column of the data to estimate.

estimator

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

replace

Whether the sample has been taken with replacement or not.

alpha

Optional value to calculate estimation error and build 1-alpha confidence interval.

Examples

Run this code
data<-rnorm(200, 100, 20)
sample<-data[srs.sample(200, 50)]
tau<-sum(data);tau
srs.estimator(200, sample, "total", alpha=0.05)


mu<-mean(data);mu
srs.estimator(200, sample, "mean", alpha=0.05)

Run the code above in your browser using DataLab