pop: Small Suppositious Sampling Example

Description Usage Format References Examples

Description

pop is a suppositious data frame for a small population with 5 elements. It is used for simple illustration of survey sampling estimators.

Usage

1

Format

A data frame with 5 observations on the following 3 variables.

id

a numeric vector of individual identification values

X

a numeric vector of first characteristic

Y

a numeric vector of second characteristic

References

Kauermann, Goeran/Kuechenhoff, Helmut (2010): Stichproben. Methoden und praktische Umsetzung mit R. Springer.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
data(pop)
print(pop)

## 1) Usage of Smean()
data(pop)
Y <- pop$Y
Y
# Draw a random sample pop size=3
set.seed(93456)
y <- sample(x = Y, size = 3)
sort(y)
# Estimation with infiniteness correction
est <- Smean(y = y, N = length(pop$Y))
est

## 2) Usage of mbes()
data(pop)
# Draw a random sample of size=3
set.seed(802016)
data <- pop[sample(1:5, size=3),]
names(data) <- c('id','x','y')
# difference estimator
mbes(formula=y~x, data=data, aux=15, N=5, method='diff', level=0.95)
# ratio estimator
mbes(formula=y~x, data=data, aux=15, N=5, method='ratio', level=0.95)
# regression estimator
mbes(formula=y~x, data=data, aux=15, N=5, method='regr', level=0.95)

Example output

Loading required package: pps
Loading required package: sampling
Loading required package: survey
Loading required package: grid
Loading required package: Matrix
Loading required package: survival

Attaching package:survivalThe following objects are masked frompackage:sampling:

    cluster, strata


Attaching package:surveyThe following object is masked frompackage:graphics:

    dotchart

  id  X  Y
1  1 11  9
2  2 11 10
3  3 11 11
4  4 21 18
5  5 21 22
[1]  9 10 11 18 22
[1]  9 11 22

Smean object: Sample mean estimate
With finite population correction: N=5

Mean estimate: 14
Standard error: 2.556
95% confidence interval: [8.9903,19.0097]


mbes object: Model Based Estimation of Population Mean
Population size N = 5, sample size n = 3

Values for auxiliary variable: 
X.mean.1 = 15, x.mean.1 = 17.6667
----------------------------------------------------------------
Difference Estimate

Mean estimate:  14 
Standard error:  0.7303 

95% confidence interval [12.5686,15.4314]


mbes object: Model Based Estimation of Population Mean
Population size N = 5, sample size n = 3

Values for auxiliary variable: 
X.mean.1 = 15, x.mean.1 = 17.6667
----------------------------------------------------------------
Ratio Estimate

Mean estimate:  14.1509 
Standard error:  0.74 

95% confidence interval [12.7006,15.6013]


mbes object: Model Based Estimation of Population Mean
Population size N = 5, sample size n = 3

Values for auxiliary variable: 
X.mean.1 = 15, x.mean.1 = 17.6667
----------------------------------------------------------------
Linear Regression Estimate

Mean estimate:  14 
Standard error:  1.0328 

95% confidence interval [11.9758,16.0242]

----------------------------------------------------------------
Linear Regression Model:
Call:
lm(formula = formula, data = data)

Residuals:
         5          4          2 
 2.000e+00 -2.000e+00  6.661e-16 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)
(Intercept)  -1.0000     6.3340  -0.158    0.900
x             1.0000     0.3464   2.887    0.212

Residual standard error: 2.828 on 1 degrees of freedom
Multiple R-squared:  0.8929,	Adjusted R-squared:  0.7857 
F-statistic: 8.333 on 1 and 1 DF,  p-value: 0.2123

samplingbook documentation built on April 3, 2021, 1:06 a.m.