rss.prop.sampling {generalRSS}R Documentation

Generate ranked set samples for proportions

Description

The rss.prop.sampling function generates ranked set samples for proportions by performing ranked set sampling directly on a given population data set using an auxiliary variable (X) and subject IDs.

Usage

rss.prop.sampling(ID, X, H, nsamp)

Arguments

ID

A numeric vector of subject IDs from the population. IDs must be unique.

X

A numeric vector of auxiliary variable used for ranking. Must have the same length as ID.

H

The RSS set size

nsamp

A numeric vector specifying the sample allocation for each stratum.

Details

This function performs balanced or unbalanced ranked set sampling for proportions from a given data set. The length of the sample allocation vector (nsamp) must match the set size (H). The subject ID and auxiliary variable (X) must have the same length.

Value

A data frame with the following columns:

ID

The sampled subjects' IDs.

rank

The rank information assigned to each sample.

Examples

## Example 1: Balanced RSS with equal sample sizes.
data(iris)
id=1:nrow(iris)
X=ifelse(iris$Sepal.Length<5.8,0,1)
rss.prop.data=rss.prop.sampling(ID=id, X=X, H=3,nsamp=c(6,6,6))

## Example 2: Unbalanced RSS with different sample sizes.
rss.prop.data=rss.prop.sampling(ID=id, X=X, H=3, nsamp=c(6,10,8))

# Check the structure of the RSS data
colnames(rss.prop.data) # include "ID", "rank", and "Y"
head(rss.prop.data$ID)
head(rss.prop.data$rank)


[Package generalRSS version 0.1.3 Index]