From ee9084a872369b470cd07c9e85c69072b9efea72 Mon Sep 17 00:00:00 2001 From: Juris Breidaks Date: Wed, 20 May 2020 13:50:25 +0300 Subject: [PATCH] Update --- package_check_build.R | 2 -- surveyplanning/DESCRIPTION | 7 +++--- surveyplanning/R/MoE_P.R | 4 ++-- surveyplanning/R/MoE_Y.R | 4 ++-- surveyplanning/R/dom_optimal_allocation.R | 8 +++---- surveyplanning/R/expsize.R | 4 ++-- surveyplanning/R/expvar.R | 4 ++-- surveyplanning/R/min_count.R | 5 ++-- surveyplanning/R/min_prop.R | 3 +-- surveyplanning/R/optsize.R | 4 ++-- .../R/prop_dom_optimal_allocation.R | 8 +++---- surveyplanning/R/round2.R | 2 +- surveyplanning/R/s2.R | 4 ++-- surveyplanning/man/MoE_P.Rd | 5 ++-- surveyplanning/man/MoE_Y.Rd | 5 ++-- surveyplanning/man/dom_optimal_allocation.Rd | 23 ++++++++++++++----- surveyplanning/man/expsize.Rd | 5 ++-- surveyplanning/man/expvar.Rd | 16 ++++++++++--- surveyplanning/man/min_count.Rd | 8 +++---- surveyplanning/man/min_prop.Rd | 6 ++--- surveyplanning/man/optsize.Rd | 14 ++++++++--- .../man/prop_dom_optimal_allocation.Rd | 22 +++++++++++++----- surveyplanning_4.0_checksums.md5 | 6 +++++ 23 files changed, 101 insertions(+), 68 deletions(-) create mode 100644 surveyplanning_4.0_checksums.md5 diff --git a/package_check_build.R b/package_check_build.R index c58fc79..2db713d 100644 --- a/package_check_build.R +++ b/package_check_build.R @@ -45,7 +45,5 @@ install.packages(paste0(package_name, "_", ver, ".zip"), repos = NULL) install.packages(paste0(package_name, "_", ver, ".tar.gz"), repos = NULL) - require(surveyplanning) -export.genkopa("2018C4") diff --git a/surveyplanning/DESCRIPTION b/surveyplanning/DESCRIPTION index 4e1a069..4254d30 100644 --- a/surveyplanning/DESCRIPTION +++ b/surveyplanning/DESCRIPTION @@ -1,8 +1,8 @@ Package: surveyplanning Type: Package Title: Survey Planning Tools -Version: 3.0 -Date: 2019-03-25 +Version: 4.0 +Date: 2020-05-20 Depends: R (>= 3.0.0) Imports: data.table (>= 1.11.4), laeken, stats Authors@R: c(person("Juris", "Breidaks", email = "rcsb@csb.gov.lv", role = c("aut", "cre")), person("Martins", "Liberts", role = "aut"), person("Janis", "Jukams", role = "aut")) @@ -15,5 +15,4 @@ URL: https://csblatvia.github.io/surveyplanning/ BugReports: https://github.com/CSBLatvia/surveyplanning/issues/ NeedsCompilation: yes LazyData: true -RoxygenNote: 6.1.1 - +RoxygenNote: 7.1.0 diff --git a/surveyplanning/R/MoE_P.R b/surveyplanning/R/MoE_P.R index ef3ecc6..c97cc72 100644 --- a/surveyplanning/R/MoE_P.R +++ b/surveyplanning/R/MoE_P.R @@ -1,6 +1,6 @@ #' Margin of error for proportion #' -#' The function computes margin of error for proportion. The calculation takes into proportion, expected response rate and design effect. +#' @description The function computes margin of error for proportion. The calculation takes into proportion, expected response rate and design effect. #' #' @param P The expected proportion for variable of interest. #' @param n The expected sample size. @@ -17,7 +17,7 @@ #' @keywords surveysampling #' #' @examples -#' library(data.table) +#' library("data.table") #' n <- 100 #' pop <- 1000 #' diff --git a/surveyplanning/R/MoE_Y.R b/surveyplanning/R/MoE_Y.R index 9a6bdfd..a1e77ad 100644 --- a/surveyplanning/R/MoE_Y.R +++ b/surveyplanning/R/MoE_Y.R @@ -1,6 +1,6 @@ #' Margin of error for count #' -#' The function computes margin of error for count. The calculation takes into proportion, expected response rate and design effect. +#' @description The function computes margin of error for count. The calculation takes into proportion, expected response rate and design effect. #' #' @param P The expected proportion for variable of interest. #' @param n The expected sample size. @@ -17,7 +17,7 @@ #' @keywords surveysampling #' #' @examples -#' library(data.table) +#' library("data.table") #' n <- 100 #' pop <- 1000 #' diff --git a/surveyplanning/R/dom_optimal_allocation.R b/surveyplanning/R/dom_optimal_allocation.R index 1a1378d..b3c49fb 100644 --- a/surveyplanning/R/dom_optimal_allocation.R +++ b/surveyplanning/R/dom_optimal_allocation.R @@ -1,6 +1,6 @@ #' Optimal sample size allocation #' -#' The function computes optimal sample size allocation over strata and domain for population. +#' @description The function computes optimal sample size allocation over strata and domain for population. #' #' @param id Variable for unit ID codes. One dimensional object convertible to one-column \code{data.table} or variable name as character, column number. #' @param Dom Optional variables used to define population domains. If supplied, values are calculated for each domain. An object convertible to \code{data.table} or variable names as character vector, column numbers. @@ -95,9 +95,9 @@ #' @keywords surveysampling #' #' @examples -#' library(laeken) -#' library(data.table) -#' data(ses) +#' library("laeken") +#' library("data.table") +#' data("ses") #' data <- data.table(ses) #' data[, H := paste(location, NACE1, size, sep = "_")] #' data[, id := .I] diff --git a/surveyplanning/R/expsize.R b/surveyplanning/R/expsize.R index cf0ef8e..88c2428 100644 --- a/surveyplanning/R/expsize.R +++ b/surveyplanning/R/expsize.R @@ -1,6 +1,6 @@ #' Sample size calculation #' -#' The function computes minimum sample size for each stratum to achieve defined precision (CV) for the estimates of totals in each stratum. The calculation takes into account expected totals, population variance, expected response rate and design effect in each stratum. +#' @description The function computes minimum sample size for each stratum to achieve defined precision (CV) for the estimates of totals in each stratum. The calculation takes into account expected totals, population variance, expected response rate and design effect in each stratum. #' #' @param Yh The expected totals for variables of interest in each stratum. Object convertible to \code{data.table}, variable names as character vector, or column numbers. #' @param H The stratum variable. One dimensional object convertible to one-column \code{data.table}, variable name as character, or column number. @@ -27,7 +27,7 @@ #' #' @keywords surveysampling #' @examples -#' library(data.table) +#' library("data.table") #' data <- data.table(H = 1:3, Yh = 10 * 1:3, #' Yh1 = 10 * 4:6, s2h = 10 * runif(3), #' s2h2 = 10 * runif(3), CVh = rep(4.9,3), diff --git a/surveyplanning/R/expvar.R b/surveyplanning/R/expvar.R index 4f55d55..c1fec0d 100644 --- a/surveyplanning/R/expvar.R +++ b/surveyplanning/R/expvar.R @@ -1,6 +1,6 @@ #' Expected precision for the estimates of totals #' -#' The function computes expected precision as variance, standard error, and coefficient of variation for the estimates. +#' @description The function computes expected precision as variance, standard error, and coefficient of variation for the estimates. #' #' @param Yh The expected totals for variables of interest in each stratum. Object convertible to \code{data.table}, variable names as character vector, or column numbers. #' @param Zh Optional variables of denominator for the expected ratio estimation in each stratum. Object convertible to \code{data.table}, variable names as character vector, or column numbers. @@ -58,7 +58,7 @@ #' @keywords surveysampling #' #' @examples -#' library(data.table) +#' library("data.table") #' data <- data.table(H = 1:3, Yh = 10 * 1:3, #' Yh1 = 10 * 4:6, s2h = 10 * runif(3), #' s2h2 = 10 * runif(3), nh = rep(4 * 1:3), diff --git a/surveyplanning/R/min_count.R b/surveyplanning/R/min_count.R index 2fc485f..9b6f7f1 100644 --- a/surveyplanning/R/min_count.R +++ b/surveyplanning/R/min_count.R @@ -1,7 +1,6 @@ #' Minimal count of respondents for the given relative margin of error #' -#' The function computes minimal proportion for the given relative margin of error. The calculation takes into sample size, population size, -#' margin of error, expected response rate and design effect. +#' @description The function computes minimal proportion for the given relative margin of error. The calculation takes into sample size, population size, margin of error, expected response rate and design effect. #' #' @param n The expected sample size. #' @param pop Population size. @@ -21,7 +20,7 @@ #' min_count(n = 15e3, pop = 2e6, RMoE = 0.1) #' #' \dontrun{ -#' library(data.table) +#' library("data.table") #' min_count(n = c(10e3, 15e3, 20e3), pop = 2e6, 0.1) #' #' n <- seq(10e3, 30e3, length.out = 11) diff --git a/surveyplanning/R/min_prop.R b/surveyplanning/R/min_prop.R index f9d60ec..ba77620 100644 --- a/surveyplanning/R/min_prop.R +++ b/surveyplanning/R/min_prop.R @@ -1,7 +1,6 @@ #' Minimal proportion for the given relative margin of error #' -#' The function computes minimal proportion for the given relative margin of error. The calculation takes into sample size, population size, -#' margin of error, expected response rate and design effect. +#' @description The function computes minimal proportion for the given relative margin of error. The calculation takes into sample size, population size, margin of error, expected response rate and design effect. #' #' @param n The expected sample size. #' @param pop Population size. diff --git a/surveyplanning/R/optsize.R b/surveyplanning/R/optsize.R index ffcf428..d18d13f 100644 --- a/surveyplanning/R/optsize.R +++ b/surveyplanning/R/optsize.R @@ -1,6 +1,6 @@ #' Optimal sample size allocation #' -#' The function computes optimal sample size allocation over strata. +#' @description The function computes optimal sample size allocation over strata. #' #' @section Details: #' If \code{s2h} and \code{Rh} is not defined, the sample allocation will be calculated as proportional allocation (proportional to the population size). @@ -32,7 +32,7 @@ #' @keywords surveysampling #' #' @examples -#' library(data.table) +#' library("data.table") #' data <- data.table(H = 1 : 3, #' s2h=10 * runif(3), #' s2h2 = 10 * runif(3), diff --git a/surveyplanning/R/prop_dom_optimal_allocation.R b/surveyplanning/R/prop_dom_optimal_allocation.R index 8513538..82950e9 100644 --- a/surveyplanning/R/prop_dom_optimal_allocation.R +++ b/surveyplanning/R/prop_dom_optimal_allocation.R @@ -1,6 +1,6 @@ #' Optimal sample size allocation for proportion #' -#' The function computes optimal sample size allocation over strata and domain for proportion. +#' @description The function computes optimal sample size allocation over strata and domain for proportion. #' #' @param H The stratum variable. One dimensional object convertible to one-column \code{data.table} or variable name as character, column number. #' @param Dom}{Variables used to define population domains. An object convertible to \code{data.table} or variable names as character vector, column numbers. @@ -39,9 +39,9 @@ #' @keywords surveysampling #' @examples -#' library(data.table) -#' library(laeken) -#' data(eusilc) +#' library("data.table") +#' library("laeken") +#' data("eusilc") #' eusilc <- data.table(eusilc) #' dataset <- eusilc[, .(poph = sum(db090)), by = c("db040")] #' dataset[, dom := "1"] diff --git a/surveyplanning/R/round2.R b/surveyplanning/R/round2.R index e0dc28e..99d1447 100644 --- a/surveyplanning/R/round2.R +++ b/surveyplanning/R/round2.R @@ -1,6 +1,6 @@ #' Rounding numbers #' -#' The function rounds the values in its first argument to the specified number of decimal places (default 0). +#' @description The function rounds the values in its first argument to the specified number of decimal places (default 0). #' #' @param x a numeric vector. #' @param n integer indicating the number of decimal places. diff --git a/surveyplanning/R/s2.R b/surveyplanning/R/s2.R index 6a32715..b5f2136 100644 --- a/surveyplanning/R/s2.R +++ b/surveyplanning/R/s2.R @@ -1,6 +1,6 @@ #' Population variance #' -#' The function to estimate population variance \eqn{S^2}. +#' @description The function to estimate population variance \eqn{S^2}. #' #' @section Details: #' If \code{w} is not defined, the result is equal to the result of the function \code{var}. @@ -16,7 +16,7 @@ #' all.equal(s2(1:10), var(1:10)) #' #' @export s2 -#' + # S^2 estimation s2 <- function(y, w = NULL) { diff --git a/surveyplanning/man/MoE_P.Rd b/surveyplanning/man/MoE_P.Rd index 114fb9c..97cc157 100644 --- a/surveyplanning/man/MoE_P.Rd +++ b/surveyplanning/man/MoE_P.Rd @@ -4,8 +4,7 @@ \alias{MoE_P} \title{Margin of error for proportion} \usage{ -MoE_P(P = 0.5, n, pop, confidence = 0.95, R = 1, deff_sam = 1, - deff_est = 1) +MoE_P(P = 0.5, n, pop, confidence = 0.95, R = 1, deff_sam = 1, deff_est = 1) } \arguments{ \item{P}{The expected proportion for variable of interest.} @@ -29,7 +28,7 @@ The estimate of margin of error for proportion. The function computes margin of error for proportion. The calculation takes into proportion, expected response rate and design effect. } \examples{ -library(data.table) +library("data.table") n <- 100 pop <- 1000 diff --git a/surveyplanning/man/MoE_Y.Rd b/surveyplanning/man/MoE_Y.Rd index 0e93b9d..d527626 100644 --- a/surveyplanning/man/MoE_Y.Rd +++ b/surveyplanning/man/MoE_Y.Rd @@ -4,8 +4,7 @@ \alias{MoE_Y} \title{Margin of error for count} \usage{ -MoE_Y(P = 0.5, n, pop, confidence = 0.95, R = 1, deff_sam = 1, - deff_est = 1) +MoE_Y(P = 0.5, n, pop, confidence = 0.95, R = 1, deff_sam = 1, deff_est = 1) } \arguments{ \item{P}{The expected proportion for variable of interest.} @@ -29,7 +28,7 @@ The estimate of margin of error for count. The function computes margin of error for count. The calculation takes into proportion, expected response rate and design effect. } \examples{ -library(data.table) +library("data.table") n <- 100 pop <- 1000 diff --git a/surveyplanning/man/dom_optimal_allocation.Rd b/surveyplanning/man/dom_optimal_allocation.Rd index d7826e9..b8fa4ed 100644 --- a/surveyplanning/man/dom_optimal_allocation.Rd +++ b/surveyplanning/man/dom_optimal_allocation.Rd @@ -4,9 +4,20 @@ \alias{dom_optimal_allocation} \title{Optimal sample size allocation} \usage{ -dom_optimal_allocation(id, Dom, H, Y, Rh = NULL, deffh = NULL, - indicator, sup_w, sup_cv, min_size = 3, correction_before = FALSE, - dataset = NULL) +dom_optimal_allocation( + id, + Dom, + H, + Y, + Rh = NULL, + deffh = NULL, + indicator, + sup_w, + sup_cv, + min_size = 3, + correction_before = FALSE, + dataset = NULL +) } \arguments{ \item{id}{Variable for unit ID codes. One dimensional object convertible to one-column \code{data.table} or variable name as character, column number.} @@ -114,9 +125,9 @@ A list with eights data objects:\cr The function computes optimal sample size allocation over strata and domain for population. } \examples{ -library(laeken) -library(data.table) -data(ses) +library("laeken") +library("data.table") +data("ses") data <- data.table(ses) data[, H := paste(location, NACE1, size, sep = "_")] data[, id := .I] diff --git a/surveyplanning/man/expsize.Rd b/surveyplanning/man/expsize.Rd index 1326ad3..b6a1888 100644 --- a/surveyplanning/man/expsize.Rd +++ b/surveyplanning/man/expsize.Rd @@ -4,8 +4,7 @@ \alias{expsize} \title{Sample size calculation} \usage{ -expsize(Yh, H, s2h, poph, Rh = NULL, deffh = NULL, CVh, - dataset = NULL) +expsize(Yh, H, s2h, poph, Rh = NULL, deffh = NULL, CVh, dataset = NULL) } \arguments{ \item{Yh}{The expected totals for variables of interest in each stratum. Object convertible to \code{data.table}, variable names as character vector, or column numbers.} @@ -40,7 +39,7 @@ A \code{data.table} is returned by the function, with variables:\cr The function computes minimum sample size for each stratum to achieve defined precision (CV) for the estimates of totals in each stratum. The calculation takes into account expected totals, population variance, expected response rate and design effect in each stratum. } \examples{ -library(data.table) +library("data.table") data <- data.table(H = 1:3, Yh = 10 * 1:3, Yh1 = 10 * 4:6, s2h = 10 * runif(3), s2h2 = 10 * runif(3), CVh = rep(4.9,3), diff --git a/surveyplanning/man/expvar.Rd b/surveyplanning/man/expvar.Rd index e3dacec..07dd5d1 100644 --- a/surveyplanning/man/expvar.Rd +++ b/surveyplanning/man/expvar.Rd @@ -4,8 +4,18 @@ \alias{expvar} \title{Expected precision for the estimates of totals} \usage{ -expvar(Yh, Zh = NULL, H, s2h, nh, poph, Rh = NULL, deffh = NULL, - Dom = NULL, dataset = NULL) +expvar( + Yh, + Zh = NULL, + H, + s2h, + nh, + poph, + Rh = NULL, + deffh = NULL, + Dom = NULL, + dataset = NULL +) } \arguments{ \item{Yh}{The expected totals for variables of interest in each stratum. Object convertible to \code{data.table}, variable names as character vector, or column numbers.} @@ -72,7 +82,7 @@ A list with three data objects: The function computes expected precision as variance, standard error, and coefficient of variation for the estimates. } \examples{ -library(data.table) +library("data.table") data <- data.table(H = 1:3, Yh = 10 * 1:3, Yh1 = 10 * 4:6, s2h = 10 * runif(3), s2h2 = 10 * runif(3), nh = rep(4 * 1:3), diff --git a/surveyplanning/man/min_count.Rd b/surveyplanning/man/min_count.Rd index 318bfec..054d1a6 100644 --- a/surveyplanning/man/min_count.Rd +++ b/surveyplanning/man/min_count.Rd @@ -4,8 +4,7 @@ \alias{min_count} \title{Minimal count of respondents for the given relative margin of error} \usage{ -min_count(n, pop, RMoE, confidence = 0.95, R = 1, deff_sam = 1, - deff_est = 1) +min_count(n, pop, RMoE, confidence = 0.95, R = 1, deff_sam = 1, deff_est = 1) } \arguments{ \item{n}{The expected sample size.} @@ -26,14 +25,13 @@ min_count(n, pop, RMoE, confidence = 0.95, R = 1, deff_sam = 1, The estimate of minimal count of respondents for the given relative margin of error. } \description{ -The function computes minimal proportion for the given relative margin of error. The calculation takes into sample size, population size, -margin of error, expected response rate and design effect. +The function computes minimal proportion for the given relative margin of error. The calculation takes into sample size, population size, margin of error, expected response rate and design effect. } \examples{ min_count(n = 15e3, pop = 2e6, RMoE = 0.1) \dontrun{ -library(data.table) +library("data.table") min_count(n = c(10e3, 15e3, 20e3), pop = 2e6, 0.1) n <- seq(10e3, 30e3, length.out = 11) diff --git a/surveyplanning/man/min_prop.Rd b/surveyplanning/man/min_prop.Rd index 6258ce1..2273bee 100644 --- a/surveyplanning/man/min_prop.Rd +++ b/surveyplanning/man/min_prop.Rd @@ -4,8 +4,7 @@ \alias{min_prop} \title{Minimal proportion for the given relative margin of error} \usage{ -min_prop(n, pop, RMoE, confidence = 0.95, R = 1, deff_sam = 1, - deff_est = 1) +min_prop(n, pop, RMoE, confidence = 0.95, R = 1, deff_sam = 1, deff_est = 1) } \arguments{ \item{n}{The expected sample size.} @@ -26,8 +25,7 @@ min_prop(n, pop, RMoE, confidence = 0.95, R = 1, deff_sam = 1, The estimate of minimal proportion for the given relative margin of error. } \description{ -The function computes minimal proportion for the given relative margin of error. The calculation takes into sample size, population size, -margin of error, expected response rate and design effect. +The function computes minimal proportion for the given relative margin of error. The calculation takes into sample size, population size, margin of error, expected response rate and design effect. } \examples{ min_prop(n = 100, pop = 1000, RMoE = 0.1) diff --git a/surveyplanning/man/optsize.Rd b/surveyplanning/man/optsize.Rd index 3c90ac9..50d5ad3 100644 --- a/surveyplanning/man/optsize.Rd +++ b/surveyplanning/man/optsize.Rd @@ -4,8 +4,16 @@ \alias{optsize} \title{Optimal sample size allocation} \usage{ -optsize(H, n, poph, s2h = NULL, Rh = NULL, deffh = NULL, - fullsampleh = NULL, dataset = NULL) +optsize( + H, + n, + poph, + s2h = NULL, + Rh = NULL, + deffh = NULL, + fullsampleh = NULL, + dataset = NULL +) } \arguments{ \item{H}{The stratum variable. One dimensional object convertible to one-column \code{data.table}, variable name as character, or column number.} @@ -46,7 +54,7 @@ If \code{Rh} is not defined, the sample allocation will be calculated as Neyman } \examples{ -library(data.table) +library("data.table") data <- data.table(H = 1 : 3, s2h=10 * runif(3), s2h2 = 10 * runif(3), diff --git a/surveyplanning/man/prop_dom_optimal_allocation.Rd b/surveyplanning/man/prop_dom_optimal_allocation.Rd index 73dd646..38133c2 100644 --- a/surveyplanning/man/prop_dom_optimal_allocation.Rd +++ b/surveyplanning/man/prop_dom_optimal_allocation.Rd @@ -4,9 +4,19 @@ \alias{prop_dom_optimal_allocation} \title{Optimal sample size allocation for proportion} \usage{ -prop_dom_optimal_allocation(H, Dom, pop = NULL, R = NULL, - deff = NULL, se_max = 0.5, prop = 0.5, min_size = 3, step = 1, - unit_level = TRUE, dataset = NULL) +prop_dom_optimal_allocation( + H, + Dom, + pop = NULL, + R = NULL, + deff = NULL, + se_max = 0.5, + prop = 0.5, + min_size = 3, + step = 1, + unit_level = TRUE, + dataset = NULL +) } \arguments{ \item{H}{The stratum variable. One dimensional object convertible to one-column \code{data.table} or variable name as character, column number.} @@ -54,9 +64,9 @@ A list with two data objects: The function computes optimal sample size allocation over strata and domain for proportion. } \examples{ -library(data.table) -library(laeken) -data(eusilc) +library("data.table") +library("laeken") +data("eusilc") eusilc <- data.table(eusilc) dataset <- eusilc[, .(poph = sum(db090)), by = c("db040")] dataset[, dom := "1"] diff --git a/surveyplanning_4.0_checksums.md5 b/surveyplanning_4.0_checksums.md5 new file mode 100644 index 0000000..3080c2a --- /dev/null +++ b/surveyplanning_4.0_checksums.md5 @@ -0,0 +1,6 @@ +fc5e2e96dfdb018ee4a88e5fe8e2c63b surveyplanning_3.0-manual.pdf +c91338e14db2ef4418b6ee6d83416a26 surveyplanning_3.0.tar.gz +f649301ad94c63e1cefaf46792a0dfe5 surveyplanning_3.0.zip +21164a7e2e24cd0bdc0c91a98fc61504 surveyplanning_4.0-manual.pdf +b0640fec71c238dd5d92c5a8e87eeaf9 surveyplanning_4.0.tar.gz +64c134867eaed85d1f3a97d67bbcccc7 surveyplanning_4.0.zip