Skip to content

Commit

Permalink
version 0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wahani authored and cran-robot committed Mar 28, 2019
1 parent b9f7490 commit 25f46de
Show file tree
Hide file tree
Showing 16 changed files with 614 additions and 327 deletions.
12 changes: 6 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Package: saeSim
Type: Package
Title: Simulation Tools for Small Area Estimation
Date: 2017-05-06
Version: 0.9.0
Version: 0.10.0
Authors@R: c(person("Sebastian", "Warnholz", role = c("aut", "cre"),
email = "[email protected]"),
person("Timo", "Schmid", role = "aut",
Expand All @@ -12,19 +11,20 @@ BugReports: https://github.com/wahani/saeSim/issues
Depends: R(>= 3.1), methods
Imports: dplyr(>= 0.2), functional, ggplot2, grDevices, MASS, utils,
spdep, stats, parallelMap
Suggests: testthat, knitr, rmarkdown
Suggests: testthat, knitr, rmarkdown, covr
Description: Tools for the simulation of data in the context of small area
estimation. Combine all steps of your simulation - from data generation
over drawing samples to model fitting - in one object. This enables easy
modification and combination of different scenarios. You can store your
results in a folder or start the simulation in parallel.
License: MIT + file LICENSE
VignetteBuilder: knitr
RoxygenNote: 6.0.1
RoxygenNote: 6.1.1
Encoding: UTF-8
NeedsCompilation: no
Packaged: 2017-05-06 18:29:58 UTC; sebastian
Packaged: 2019-03-28 10:03:42 UTC; sebastian
Author: Sebastian Warnholz [aut, cre],
Timo Schmid [aut]
Maintainer: Sebastian Warnholz <[email protected]>
Repository: CRAN
Date/Publication: 2017-05-08 11:54:46 UTC
Date/Publication: 2019-03-28 12:50:03 UTC
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2016-2017
YEAR: 2016-2018
COPYRIGHT HOLDER: Sebastian Warnholz
29 changes: 15 additions & 14 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
ab607c82e1fdf5496174afcf09e33a78 *DESCRIPTION
1034d57dd62685e8cdce2025a68f34fa *LICENSE
25554331e695722dd1382c3b99a8e63a *DESCRIPTION
6cc9f87b1928caeb148b18011cf4ee05 *LICENSE
5ce358f32242b32824ba95e5304c4e66 *NAMESPACE
79ace773538fc6b48801b60a0e7d1c84 *NEWS
6c961327a0df16302c0de75e625bf812 *NEWS
66a13d145e8eb3eb090f787a6b5df148 *R/00-pipe.R
47406cfc6ed3b5fe4c32eeff4bf291b7 *R/00-sim-lib.R
3535f64cc58acebc60da42d9564f06d8 *R/01-as.data.frame.R
067c379cfbe2e5fdd2115b80626a208a *R/01-autoplot.R
24ee7f08a97435aaef6a134a2124b388 *R/01-helper-lib.R
cd558c2af82febf2c065682365d1e4b1 *R/01-helper-lib.R
70de0d4ff6461c43f7b7b82e973bb3da *R/01-plot.R
7a5fd54a37c49ea311077d21f8ab889a *R/01-select_cont.R
6f0ac668bf7a70bb6740a8e4f39fbe07 *R/01-show.R
Expand All @@ -17,7 +17,7 @@ cc94419e25929b14cc3aff5b7db1acd7 *R/01-sim_setup.R
bba415d0f20dab5dbedd1ae9fbb29180 *R/03-base-lib.R
06f2c1782ccc1706db0665aeae0fe4c2 *R/03-comp_var.R
9ad428e72c3d1be87aa3a5bd84387b6d *R/03-generator.R
2ed44af581d5f89b77facbbb7ba3c4ab *R/03-sample.R
07e3ddfdc6889754154e80696f0fd3da *R/03-sample.R
6d3fd3eeaeb33d9031d8c63134f90c21 *R/03-sim_agg.R
59d21bf30a4c9e7af89365c0724e3063 *R/03-sim_base.R
6914ff690aa490737ace6dbb67289fd5 *R/03-sim_comp.R
Expand All @@ -30,12 +30,13 @@ d685548c5463673e48ce358d8cdf4dcd *R/03-sim_gen_cont.R
4fbf843d2a549fee8a685c3dfdc25301 *R/03-sim_sample.R
c453593c13649fde1aba4f266cb5a292 *R/03-sim_simName.R
a34255c8c34882dc7e7a1de250cb7902 *R/NAMESPACE.R
405df56ccf7c0ec752ca017eff47f462 *build/vignette.rds
be1d7b0747d41e11beba6290c12a89a9 *build/vignette.rds
a5711c719a6187c0f9fdb86198a02aed *inst/CITATION
b987aa6937809d8efd270ba4126c7c54 *inst/doc/Introduction.R
e8f8181faa2e8ffdfd774f15efc0f0ba *inst/doc/Introduction.Rmd
08c48bf5d178c686dfe64f98d09e07ef *inst/doc/Introduction.html
cd79353983d1110643476ad4c3165b8c *inst/doc/Introduction.html
5d33973e3050326c6a18cd258704ccb0 *man/agg_all.Rd
0593da012b629a7c218bdf5e6d317e34 *man/as.data.frame.sim_setup.Rd
b010267195ef14b4a6364d620278b005 *man/as.data.frame.sim_setup.Rd
a1fd870dfd8f9e772987433700b20c14 *man/autoplot.Rd
1720f24e9a3dfd860b0eadaa465ba0d0 *man/base_add_id.Rd
a5a831a9cfae92a9b022cb1865cba211 *man/base_id.Rd
Expand All @@ -44,18 +45,18 @@ a5a831a9cfae92a9b022cb1865cba211 *man/base_id.Rd
91a1d4d9ee45c1c81ec119744ab861d3 *man/pipe.Rd
e5d8a559df7bf80e25288b41ba574946 *man/plot.sim_setup.Rd
b879e3b9d40bd02c618e13e7c22159ea *man/read_data.Rd
a88aa46a906d114f2c4680da04ac01c3 *man/sampling.Rd
b93b6b8895dca7dba3e122c0f0617407 *man/sampling.Rd
ae09fb2d56ddb1a949e9f41e4cbf4d06 *man/showMethods.Rd
604d519a54ad563768177a8095259065 *man/sim.Rd
694b3e1a42d394ad625aa9317e6cec47 *man/sim_agg.Rd
b6d59ff692f4b5ed9852eaf7bb65dc47 *man/sim_base.Rd
87b71dd658c9eb6f90aadb1c98c7f311 *man/sim_comp.Rd
7eed1e93e7aabace8dc56c521593afaa *man/sim_comp_preconf.Rd
9d4c5fe6073e682ae7af1ebe32958a2a *man/sim_gen.Rd
f51d6ac9fc7408c747d35d385e2d3909 *man/sim_gen_cont.Rd
0d81334e575750f881f71987171cd8cc *man/sim_gen_cont.Rd
24261de845608d67b58d3e317fe15756 *man/sim_gen_preconf.Rd
05615f913758cb323205270d32d19c2f *man/sim_resp.Rd
cb4ea4e5ef5d695f64c34dafdbf46012 *man/sim_sample.Rd
1fc49981b22203021843482e8d8d5f5e *man/sim_resp.Rd
b32f6f99192bc7fadabba489cd9b64cb *man/sim_sample.Rd
77d0d831f919afca592ec231ce31b630 *man/sim_setup_preconfigured.Rd
d285fa483cfb885cd310a29a71b2b974 *man/sim_simName.Rd
fcc82527fa19b3c86027ad157428ee08 *man/summary-sim_setup-method.Rd
Expand All @@ -68,10 +69,10 @@ f257af9d8e7b54525025461389441886 *tests/testthat/test-preserve_attributes.R
32d14fc4c48d20abed634805dcf413aa *tests/testthat/test-sim.R
dac630d0fa14302f2bd706e7db7b2751 *tests/testthat/test-sim_agg.R
65558a7657818884eb5df934cd70fe69 *tests/testthat/test-sim_base.R
8e18a5a29f1db5b802a4f4d95b49218c *tests/testthat/test-sim_comp.R
3f0be6296c1646ec135373839dac33fa *tests/testthat/test-sim_comp.R
e3ab6dfad3fe60991b837ec40b7022e6 *tests/testthat/test-sim_generate.R
eb92ecb054535c5516c4db27399d7cae *tests/testthat/test-sim_resp.R
05c9829b204077cd43751c7d4a204a56 *tests/testthat/test-sim_sample.R
feff03b423612c5c9d43f15ce8140407 *tests/testthat/test-sim_sample.R
9da7507d774e74657b5c78e963f97b0d *tests/testthat/test-sim_setup.R
7295e37ed8b8609caa9f5af1a6c4deef *tests/testthat/test-sim_simName.R
e8f8181faa2e8ffdfd774f15efc0f0ba *vignettes/Introduction.Rmd
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Version 0.10.0
- Minor fixes to documentation
- Minor bugfixes
- CITATION file

Version 0.9.0
- CRAN release

Expand Down
4 changes: 2 additions & 2 deletions R/01-helper-lib.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ mutate_wrapper <- function(...) {
mc <- match.call(expand.dots = TRUE)
mc[[1L]] <- quote(mutate)
mc[[length(mc) + 1]] <- quote(dat)

retFun <- function(dat) {
eval(mc) %>% as.data.frame
}

preserve_attributes(retFun)
}

Expand Down
52 changes: 29 additions & 23 deletions R/03-sample.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
#' Sampling functions
#'
#' These functions are intended to be used with \code{\link{sim_sample}} and not interactively. They are wrappers around \link[dplyr]{sample_frac} and \link[dplyr]{sample_n}.
#'
#'
#' These functions are intended to be used with \code{\link{sim_sample}} and not
#' interactively. They are wrappers around \link[dplyr]{sample_frac} and
#' \link[dplyr]{sample_n}.
#'
#' @param groupVars character with names of variables to be used for grouping.
#'
#'
#' @inheritParams dplyr::sample_frac
#'
#'
#' @details \code{sample_numbers} is a vectorized version of \code{sample_number}.
#'
#' \code{sample_cluster_number} and \code{sample_cluster_fraction} will sample clusters (all units in a cluster).
#'
#'
#' \code{sample_cluster_number} and \code{sample_cluster_fraction} will sample
#' clusters (all units in a cluster).
#'
#' @rdname sampling
#' @export
#'
#'
#' @examples
#' sim_base_lm() %>% sim_sample(sample_number(5))
#' sim_base_lm() %>% sim_sample(sample_fraction(0.5))
Expand All @@ -22,11 +25,13 @@ sample_fraction <- function(size, replace = FALSE, weight = NULL, groupVars = NU
force(size); force(replace); force(weight); force(groupVars)
function(dat) {
if(is.null(groupVars)) {
dat %>% sample_frac(size = size, replace = replace, weight = weight)
dat %>% sample_frac(size = size, replace = replace, weight = !!weight)
} else {
attributesToKeep <- attributes(dat)[!(names(attributes(dat)) %in% names(attributes(data.frame())))]
dat <- group_by_(dat, groupVars) %>%
sample_frac(size = size, replace = replace, weight = weight) %>% as.data.frame
attributesToKeep <- attributes(dat)[
!(names(attributes(dat)) %in% names(attributes(data.frame())))]
dat <- group_by_(dat, groupVars) %>%
sample_frac(size = size, replace = replace, weight = !!weight) %>%
as.data.frame
attributes(dat) <- c(attributes(dat), attributesToKeep)
dat
}
Expand All @@ -39,12 +44,13 @@ sample_number <- function(size, replace = FALSE, weight = NULL, groupVars = NULL
force(size); force(replace); force(weight); force(groupVars)
function(dat) {
if(is.null(groupVars)) {
dat %>% sample_n(size = size, replace = replace, weight = weight)
dat %>% sample_n(size = size, replace = replace, weight = !!weight)
} else {
attributesToKeep <- attributes(dat)[!(names(attributes(dat)) %in% names(attributes(data.frame())))]
dat <- group_by_(dat, groupVars) %>%
sample_n(size = size, replace = replace, weight = weight) %>% as.data.frame

attributesToKeep <- attributes(dat)[
!(names(attributes(dat)) %in% names(attributes(data.frame())))]
dat <- group_by_(dat, groupVars) %>%
sample_n(size = size, replace = replace, weight = !!weight) %>%
as.data.frame
attributes(dat) <- c(attributes(dat), attributesToKeep)
dat
}
Expand All @@ -62,8 +68,8 @@ sample_numbers <- function(size, replace = FALSE, groupVars = NULL) {
sample_cluster_number <- function(size, replace = FALSE, weight = NULL, groupVars) {
force(size); force(replace); force(weight); force(groupVars)
sample_fun <- function(dat) {
selectedGroups <- dat[groupVars] %>% unique %>%
sample_n(size = size, replace = replace, weight = weight) %>%
selectedGroups <- dat[groupVars] %>% unique %>%
sample_n(size = size, replace = replace, weight = !!weight) %>%
as.data.frame
left_join(selectedGroups, dat, by = groupVars)
}
Expand All @@ -75,10 +81,10 @@ sample_cluster_number <- function(size, replace = FALSE, weight = NULL, groupVar
sample_cluster_fraction <- function(size, replace = FALSE, weight = NULL, groupVars) {
force(size); force(replace); force(weight); force(groupVars)
sample_fun <- function(dat) {
selectedGroups <- dat[groupVars] %>% unique %>%
sample_frac(size = size, replace = replace, weight = weight) %>%
selectedGroups <- dat[groupVars] %>% unique %>%
sample_frac(size = size, replace = replace, weight = !!weight) %>%
as.data.frame
left_join(selectedGroups, dat, by = groupVars)
}
preserve_attributes(sample_fun)
}
}
Binary file modified build/vignette.rds
Binary file not shown.
14 changes: 14 additions & 0 deletions inst/CITATION
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
bibentry(
"article",
key="Warnholz_Schmid_2016",
title="Simulation Tools for Small Area Estimation: Introducing the R-package saeSim",
volume=45,
url="https://www.ajs.or.at/index.php/ajs/article/view/vol45-1-4",
DOI="10.17713/ajs.v45i1.89",
number=1,
journal="Austrian Journal of Statistics",
author=c(person("Sebastian", "Warnholz"), person("Timo", "Schmid")),
year=2016,
month="Feb.",
pages="55-69"
)
Loading

0 comments on commit 25f46de

Please sign in to comment.