Title: | PPS Sampling |
---|---|
Description: | Functions to select samples using PPS (probability proportional to size) sampling. The package also includes a function for stratified simple random sampling, a function to compute joint inclusion probabilities for Sampford's method of PPS sampling, and a few utility functions. The user's guide pps-ug.pdf is included in the .../pps/doc directory. The methods are described in standard survey sampling theory books such as Cochran's "Sampling Techniques"; see the user's guide for references. |
Authors: | Jack G. Gambino <[email protected]> |
Maintainer: | Jack G. Gambino <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0 |
Built: | 2025-02-16 04:15:17 UTC |
Source: | https://github.com/cran/pps |
See user's guide
See the user's guide, pps-ug.pdf, for more information.
See user's guide
See the user's guide, pps-ug.pdf, for more information.
Randomize the order of units within each stratum
permuteinstrata(stratsizes)
permuteinstrata(stratsizes)
stratsizes |
A vector containing the size of each stratum |
Returns the vector of permuted indices. In the example below, the returned vector has 29 elements.
See the user's guide, pps-ug.pdf, for more information.
stratsizes <- c(9,10,10) # strata have 9, 10 and 10 units, respectively permuteinstrata(stratsizes)
stratsizes <- c(9,10,10) # strata have 9, 10 and 10 units, respectively permuteinstrata(stratsizes)
Use PPS systematic sampling to select a single unit out of N
pps1(sizes)
pps1(sizes)
sizes |
A vector of the sizes of the units in the population |
Returns the index of the unit that was selected
See the user's guide, pps-ug.pdf, for more information.
sizes <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) sampleindex <- pps1(sizes)
sizes <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) sampleindex <- pps1(sizes)
Use PPS systematic sampling to select a sample of n units out of N
ppss(sizes,n)
ppss(sizes,n)
sizes |
A vector of the sizes of the units in the population |
n |
The sample size |
Returns the indices of the units that were selected in the sample
See the user's guide, pps-ug.pdf, for more information.
sizes <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) sampleindices <- ppss(sizes,4)
sizes <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) sampleindices <- ppss(sizes,4)
In each stratum, select a sample using pps systematic sampling
ppssstrat(sizes,stratum,n)
ppssstrat(sizes,stratum,n)
sizes |
A vector of the sizes of the units in the population, sorted by stratum |
stratum |
A vector of stratum codes, in the same order |
n |
A vector containing the sample size in each stratum |
Returns the indices of the units that were selected in the sample
ppssstrat
calls ppss
once per stratum.
See the user's guide, pps-ug.pdf, for more information.
sizes <- c(1:5,10:6)*10 strat <- c(1,1,1,2,2,3,3,3,3,3) n <- c(2,1,3) ppssstrat(sizes,strat,n)
sizes <- c(1:5,10:6)*10 strat <- c(1,1,1,2,2,3,3,3,3,3) n <- c(2,1,3) ppssstrat(sizes,strat,n)
Use PPS sampling to select a sample of n units out of N with replacement
ppswr(sizes,n)
ppswr(sizes,n)
sizes |
A vector of the sizes of the units in the population |
n |
The sample size |
Returns the indices of the units that were selected in the sample
See the user's guide, pps-ug.pdf, for more information.
sizes <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) sampleindices <- ppswr(sizes,4)
sizes <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) sampleindices <- ppswr(sizes,4)
Use Sampford's method to select a PPS sample of units
sampford(size,n)
sampford(size,n)
size |
A vector of the sizes of the units in the population |
n |
The sample size |
Returns the indices of the units that were selected in the sample
The function sampfordpi
can be used to compute joint inclusion
probabilities for this method.
See the user's guide, pps-ug.pdf, for more information.
size <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) sampleindices <- sampford(size,4)
size <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) sampleindices <- sampford(size,4)
Compute joint inclusion probabilities for Sampford's method of PPS sampling
sampfordpi(sizes,n)
sampfordpi(sizes,n)
sizes |
A vector of the sizes of the units in the population |
n |
The sample size |
Returns a matrix with the inclusion probability pi(i) for each unit i in the population and with the joint inclusion probability pi(i,j) of units i and j in position (i,j) in the matrix, where i and j are not equal. Note that the size of the matrix is NxN, where N is the population size.
The function sampford
can be used to select a sample
using Sampford's method.
See the user's guide, pps-ug.pdf, for more information.
sizes <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) piij <- sampfordpi(sizes,4) weights <- 1/diag(piij) # the weights one would use for estimation
sizes <- c(9,2,5,17,4,21,15,7,4,11,23,23,14) piij <- sampfordpi(sizes,4) weights <- 1/diag(piij) # the weights one would use for estimation
See user's guide
sizesok(size,n)
sizesok(size,n)
size |
A vector of the sizes of the units in the population |
n |
The sample size |
Returns the number of 'bad' units
See the user's guide, pps-ug.pdf, for more information.
In each stratum, select a simple random sample
stratsrs(stratum,nh)
stratsrs(stratum,nh)
stratum |
A vector of stratum codes, sorted by stratum |
nh |
A vector containing the sample size in each stratum |
Returns the indices of the units that were selected in the sample
See the user's guide, pps-ug.pdf, for more information.
strat <- c(1,1,1,1,1,2,2,2,3,3,3,3,3,3,3) # stratum 1 has 5 units, etc. nh <- c(2,1,3) # select 2 units from stratum 1, 1 from stratum 2 and 3 from 3 stratsrs(strat,nh)
strat <- c(1,1,1,1,1,2,2,2,3,3,3,3,3,3,3) # stratum 1 has 5 units, etc. nh <- c(2,1,3) # select 2 units from stratum 1, 1 from stratum 2 and 3 from 3 stratsrs(strat,nh)
Given a vector of sorted stratum indicators, returns the number of units in each stratum
stratumsizes(stratum)
stratumsizes(stratum)
stratum |
A vector of sorted stratum indicators |
Returns the number of units in each stratum
See the user's guide, pps-ug.pdf, for more information.