Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Juris Breidaks committed May 20, 2020
1 parent 0afddad commit ee9084a
Show file tree
Hide file tree
Showing 23 changed files with 101 additions and 68 deletions.
2 changes: 0 additions & 2 deletions package_check_build.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")

7 changes: 3 additions & 4 deletions surveyplanning/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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"))
Expand All @@ -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
4 changes: 2 additions & 2 deletions surveyplanning/R/MoE_P.R
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -17,7 +17,7 @@
#' @keywords surveysampling
#'
#' @examples
#' library(data.table)
#' library("data.table")
#' n <- 100
#' pop <- 1000
#'
Expand Down
4 changes: 2 additions & 2 deletions surveyplanning/R/MoE_Y.R
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -17,7 +17,7 @@
#' @keywords surveysampling
#'
#' @examples
#' library(data.table)
#' library("data.table")
#' n <- 100
#' pop <- 1000
#'
Expand Down
8 changes: 4 additions & 4 deletions surveyplanning/R/dom_optimal_allocation.R
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions surveyplanning/R/expsize.R
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions surveyplanning/R/expvar.R
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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),
Expand Down
5 changes: 2 additions & 3 deletions surveyplanning/R/min_count.R
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions surveyplanning/R/min_prop.R
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions surveyplanning/R/optsize.R
Original file line number Diff line number Diff line change
@@ -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).
Expand Down Expand Up @@ -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),
Expand Down
8 changes: 4 additions & 4 deletions surveyplanning/R/prop_dom_optimal_allocation.R
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion surveyplanning/R/round2.R
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions surveyplanning/R/s2.R
Original file line number Diff line number Diff line change
@@ -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}.
Expand All @@ -16,7 +16,7 @@
#' all.equal(s2(1:10), var(1:10))
#'
#' @export s2
#'


# S^2 estimation
s2 <- function(y, w = NULL) {
Expand Down
5 changes: 2 additions & 3 deletions surveyplanning/man/MoE_P.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions surveyplanning/man/MoE_Y.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions surveyplanning/man/dom_optimal_allocation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions surveyplanning/man/expsize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions surveyplanning/man/expvar.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions surveyplanning/man/min_count.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions surveyplanning/man/min_prop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ee9084a

Please sign in to comment.