sampling {simFrame}R Documentation

Random sampling

Description

Functions for random sampling.

Usage

srs(N, size, replace = FALSE)

ups(N, size, prob, replace = FALSE)

Arguments

N a non-negative integer giving the number of observations from which to sample.
size a non-negative integer giving the number of observations to sample.
prob a numeric vector giving the probability weights.
replace a logical indicating whether sampling should be performed with or without replacement.

Details

srs and ups are wrappers for simple random sampling and unequal probability sampling, respectively. Both functions make use of sample.

Value

An integer vector giving the indices of the sampled observations.

Author(s)

Andreas Alfons, alfons@statistik.tuwien.ac.at

See Also

SampleControl, setup, sample

Examples

## simple random sampling without replacement
srs(10, 5)

## simple random sampling with replacement
srs(5, 10, replace = TRUE)

## unequal probability sampling without replacement
ups(10, 5, prob = 1:10)

## unequal probability sampling with replacement
ups(5, 10, prob = 1:5, replace = TRUE)

[Package simFrame version 0.1.1 Index]