MyNixOS website logo
Description

Dynamic Survey Sampling Solutions.

A robust solution employing the SRS (Simple Random Sampling), systematic and PPS (Probability Proportional to Size) sampling methods, ensuring a methodical and representative selection of data. Seamlessly allocate predetermined allocations to smaller levels.

samplingin

CRANstatus Totaldownload Mentioned in Awesome Official Statistics

Overview

samplingin is a robust solution employing SRS (Simple Random Sampling), systematic and PPS (Probability Proportional to Size) sampling methods, ensuring a methodical and representative selection of data. Seamlessly allocate predetermined allocations to smaller levels.

  • get_allocation() allocate predetermined allocations to smaller levels using proportional allocation method
  • doSampling() samples selection using srs, systematic or PPS (Probability Proportional to Size) sampling method based on certain allocation.

Installation

install.packages("samplingin")

Usage

library(samplingin)
library(magrittr)
library(dplyr)

contoh_alokasi = alokasi_dt %>%
    select(-n_primary) %>%
    mutate(nasional = 1)

alokasi_dt = get_allocation(
    data = contoh_alokasi
    , alokasi = 100
    , group = c("nasional")
    , pop_var = "jml_kabkota"
 )
 
# Simple Random Sampling (SRS)
dtSampling_srs = doSampling(
  pop         = pop_dt
  , alloc     = alokasi_dt
  , nsample   = "n_primary"
  , type      = "U"
  , ident     = c("kdprov")
  , method    = "srs"
  , auxVar    = "Total"
  , seed      = 7892
)

# Population data with flag sample
pop_dt = dtSampling_srs$pop

# Selected Samples
dsampel = dtSampling_srs$sampledf

# Details of sampling process
rincian = dtSampling_srs$details

# PPS Sampling 
dtSampling_pps = doSampling(
    pop       = pop_dt
    , alloc   = alokasi_dt
    , nsample = "n_primary"
    , type    = "U"
    , ident   = c("kdprov")
    , method  = "pps"
    , auxVar  = "Total"
    , seed    = 1234
)

# Population data with flag sample
pop_dt = dtSampling_pps$pop

# Selected Samples
sampledf = dtSampling_pps$sampledf

# Details of sampling process
details = dtSampling_pps$details

# Systemtic Sampling 
dtSampling_sys = doSampling(
    pop       = pop_dt
    , alloc   = alokasi_dt
    , nsample = "n_primary"
    , type    = "U"
    , ident   = c("kdprov")
    , method  = "systematic"
    , seed    = 4321
)

# Population data with flag sample
pop_dt = dtSampling_sys$pop

# Selected Samples
sampledf = dtSampling_sys$sampledf

# Details of sampling process
details = dtSampling_sys$details

# Systematic Sampling (Secondary Samples)

alokasi_dt_p = alokasi_dt %>%
  mutate(n_secondary = 2 * n_primary)

dtSampling_sys_p = doSampling(
  pop           = dtSampling_sys$pop
  , alloc       = alokasi_dt_p
  , nsample     = "n_secondary"
  , type        = "P"
  , ident       = c("kdprov")
  , method      = "systematic"
  , seed        = 6789
  , is_secondary = TRUE
)

# Population data with flag sample
pop_dt = dtSampling_sys_p$pop

# Selected Samples
dsampel = dtSampling_sys_p$sampledf

# Details of sampling process
rincian = dtSampling_sys_p$details

# Systematic Sampling with predetermined random number (predetermined_rn parameter)
alokasi_dt_rn = alokasi_dt %>% rowwise() %>% mutate(ar = runif(n(),0,1)) %>% ungroup

dtSampling_sys = doSampling(
    pop = pop_dt
    , alloc    = alokasi_dt_rn
    , nsample  = "n_primary"
    , type     = "U"
    , ident    = c("kdprov")
    , method   = "systematic"
    , predetermined_rn = "ar"
    , seed     = 4321
)

# Population data with flag sample
pop_dt = dtSampling_sys$pop

# Selected Samples
sampledf = dtSampling_sys$sampledf

# Details of sampling process
details = dtSampling_sys$details
Metadata

Version

1.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows