Skip to content

Commit 865e57d

Browse files
authored
Merge pull request #15 from biometryhub/dev
Dev
2 parents c8ec53a + cdc6adb commit 865e57d

32 files changed

+496
-94
lines changed

DESCRIPTION

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Type: Package
2-
Package: RankedSetSampling
2+
Package: InPlotSampling
33
Title: Easing the Application of Ranked Set Sampling in Practice
44
Version: 0.1.0
55
Date: 2021-02-09
@@ -11,15 +11,15 @@ Authors@R: c(
1111
comment = c(ORCID = "0000-0001-5291-3600")),
1212
person("Peter", "Kasprzak", , "peter.kasprzak@adelaide.edu.au", role = "aut")
1313
)
14-
Description: The RankedSetSampling package provides a way for researchers
14+
Description: The InPlotSampling package provides a way for researchers
1515
to easily implement Ranked Set Sampling in practice. Ranked Set
1616
Sampling was originally described by McIntyre (1952) (reprinted in
1717
2005) <doi:10.1198/000313005X54180>. This package takes work by Omer
1818
and Kravchuk (2021) <https://doi.org/10.1007/s13253-021-00439-1> and
1919
enables easy use of the methods.
2020
License: MIT + file LICENSE
21-
URL: https://biometryhub.github.io/RankedSetSampling/
22-
BugReports: https://github.com/biometryhub/RankedSetSampling/issues
21+
URL: https://biometryhub.github.io/InPlotSampling/
22+
BugReports: https://github.com/biometryhub/InPlotSampling/issues
2323
Depends:
2424
R (>= 3.5.0)
2525
Imports:
@@ -36,4 +36,4 @@ LinkingTo:
3636
Encoding: UTF-8
3737
LazyData: true
3838
Roxygen: list(markdown = TRUE)
39-
RoxygenNote: 7.3.1
39+
RoxygenNote: 7.3.2

NAMESPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ export(rss_jps_estimate)
66
export(rss_sample)
77
export(sbs_pps_estimate)
88
export(sbs_pps_sample)
9+
export(two_stage_cluster_sample)
910
importFrom(Rcpp,sourceCpp)
1011
importFrom(stats,aggregate)
1112
importFrom(stats,qt)
1213
importFrom(stats,rnorm)
1314
importFrom(stats,sd)
1415
importFrom(stats,var)
15-
useDynLib(RankedSetSampling, .registration = TRUE)
16+
useDynLib(InPlotSampling, .registration = TRUE)

R/CoefF.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#' This function computes the coefficient of variance estimator
22
#'
3-
#' @param H Set size for each raking group.
3+
#' @param H Set size for each ranking group.
44
#' @param n Sample size.
55
#'
66
#' @return

R/RankedSetSampling-package.R renamed to R/InPlotSampling-package.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#' @name RankedSetSampling
1+
#' @name InPlotSampling
22
"_PACKAGE"
33

44
# The following block is used by usethis to automatically manage
55
# roxygen namespace tags. Modify with care!
66
## usethis namespace: start
77
#' @importFrom Rcpp sourceCpp
8-
#' @useDynLib RankedSetSampling, .registration = TRUE
8+
#' @useDynLib InPlotSampling, .registration = TRUE
99
## usethis namespace: end
1010
NULL
1111

R/RcppExports.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
2+
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
3+
4+
#' @keywords internal
5+
pascal <- function(m, popsize, set) {
6+
.Call(`_InPlotSampling_pascal`, m, popsize, set)
7+
}
8+

R/jps_estimate.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#' Computes the estimator for JPS data
22
#'
33
#' @param data The data to use for estimation.
4-
#' @param set_size Set size for each raking group.
4+
#' @param set_size Set size for each ranking group.
55
#' @param replace Logical (default `TRUE`). Sample with replacement?
66
#' @param model_based An inference mode:
77
#' - `FALSE`: design based inference

R/jps_estimate_single.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#'
33
#' @param ranks Ranks of Y.
44
#' @param y Response measurements.
5-
#' @param set_size Set size for each raking group.
5+
#' @param set_size Set size for each ranking group.
66
#' @param N Finite population size.
77
#' @param coef Coefficients used in variance computation when sample size is n.
88
#' @param coef_del Coefficients used in variance computation when the i-th unit is deleted.

R/jps_sample.R

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#' Generate JPS sampling on the provided population.
22
#'
3-
#' @inheritParams rss_sample
3+
#' @param pop Population that will be sampled.
4+
#' @param n Sample size.
5+
#' @param H Set size for each ranking group.
6+
#' @param K Number of rankers.
47
#' @param tau A parameter which controls ranking quality.
8+
#' @param replace A boolean which specifies whether to sample with replacement or not.
9+
#' @param with_index A boolean which specifies whether to return the index of the sampled population.
510
#'
611
#' @return A matrix with ranks from each ranker.
712
#' @export
@@ -36,10 +41,11 @@
3641
#' #> [9,] 8.701285 2 1 2
3742
#' #> [10,] 13.323884 3 3 3
3843
#'
39-
jps_sample <- function(pop, n, H, tau, K, replace = FALSE) {
40-
verify_jps_params(pop, n, H, tau, K, replace)
44+
jps_sample <- function(pop, n, H, tau, K, replace = FALSE, with_index = FALSE) {
45+
verify_jps_params(pop, n, H, tau, K, replace, with_index)
4146

42-
sampling_matrix <- matrix(sample(pop, n * H, replace = replace), ncol = H, nrow = n)
47+
sampling_indices <- sample(seq_along(pop), n * H, replace = replace)
48+
sampling_matrix <- matrix(pop[sampling_indices], ncol = H, nrow = n)
4349

4450
# rank each SRS unit post experimentally
4551
jps_matrix <- matrix(0, ncol = K + 1, nrow = n)
@@ -55,6 +61,10 @@ jps_sample <- function(pop, n, H, tau, K, replace = FALSE) {
5561
}
5662

5763
colnames(jps_matrix) <- c("Y", paste0("R", 1:K))
64+
if (with_index) {
65+
jps_matrix <- cbind(sampling_indices[1:n], jps_matrix)
66+
colnames(jps_matrix)[1] <- "i"
67+
}
68+
5869
return(jps_matrix)
5970
}
60-
#' @export

R/rss_jps_estimate.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#' taus <- sigma * sqrt(1 / rhos^2 - 1)
3737
#' population <- qnorm((1:population_size) / (population_size + 1), mu, sigma)
3838
#'
39-
#' data <- RankedSetSampling::jps_sample(population, n, H, taus, n_rankers, with_replacement)
39+
#' data <- InPlotSampling::jps_sample(population, n, H, taus, n_rankers, with_replacement)
4040
#' data <- data[order(data[, 2]), ]
4141
#'
4242
#' rss_jps_estimate(
@@ -75,7 +75,7 @@
7575
#' x <- population + tau * rnorm(population_size, 0, 1)
7676
#'
7777
#' population <- cbind(population, x)
78-
#' data <- RankedSetSampling::rss_sample(population, n, H, n_rankers, with_replacement)
78+
#' data <- InPlotSampling::rss_sample(population, n, H, n_rankers, with_replacement)
7979
#' data <- data[order(data[, 2]), ]
8080
#'
8181
#' rss_estimates <- rss_jps_estimate(

R/rss_sample.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ rss_sample <- function(pop, n, H, K, replace = FALSE) {
5050
#'
5151
#' @param pop Population that will be sampled with an auxiliary parameter in the second column.
5252
#' @param n Sample size.
53-
#' @param H Set size for each raking group.
53+
#' @param H Set size for each ranking group.
5454
#' @param K Number of rankers.
5555
#'
5656
#' @return A matrix with ranks from each ranker.

0 commit comments

Comments
 (0)