Sample 0 Observations from a Stratum using Sampling Package in R

85 views Asked by At

I am using the same script across varying subsets of data. Encountered one subset of data where there are 0 observations from the test group, therefore need to select 0 observations from the control group.

Is there some syntax or something I am missing to select 0 observations?

    library("sampling")

    st <- replicate(10, strata(df,stratanames=c("Stratum"),size=c(2,16,20,0,19,5,26), method="srswor"))
1

There are 1 answers

0
San On

I also sometimes needed to select zero samples from one or more stratum but sampling::strata function never allowed it.

I ended up using pps::stratsrs function in such situations which works perfectly well and can give zero samples from any stratum you specify. Package available at https://cran.r-project.org/web/packages/pps/index.html.

Can anyone suggest other stratified sampling functions (from any package) which can take 0 (zero) in the vector of stratum sample sizes?