Skip to content

Commit

Permalink
version 2.8.5
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpkeil1 authored and cran-robot committed Dec 12, 2021
1 parent cbd0b01 commit 46f062f
Show file tree
Hide file tree
Showing 23 changed files with 199 additions and 110 deletions.
22 changes: 10 additions & 12 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
Package: qgcomp
Title: Quantile G-Computation
Version: 2.8.0
Date: 2021-07-16
Version: 2.8.5
Date: 2021-12-12
Authors@R:
person(given = "Alexander",
family = "Keil",
role = c("aut", "cre"),
email = "akeil@unc.edu")
person("Alexander", "Keil", , "akeil@unc.edu", role = c("aut", "cre"))
Author: Alexander Keil [aut, cre]
Maintainer: Alexander Keil <akeil@unc.edu>
Description: G-computation for a set of time-fixed exposures
with quantile-based basis functions, possibly under linearity and
Description: G-computation for a set of time-fixed exposures with
quantile-based basis functions, possibly under linearity and
homogeneity assumptions. This approach estimates a regression line
corresponding to the expected change in the outcome (on the link
basis) given a simultaneous increase in the quantile-based category
Expand All @@ -20,16 +17,17 @@ Description: G-computation for a set of time-fixed exposures
Alexandra J. White (2019) A quantile-based g-computation approach to
addressing the effects of exposure mixtures; <doi:10.1289/EHP5838>.
License: GPL (>= 2)
URL: https://github.com/alexpkeil1/qgcomp/
BugReports: https://github.com/alexpkeil1/qgcomp/issues
Depends: R (>= 3.5.0)
Imports: arm, future, future.apply, generics, ggplot2 (>= 3.3.0),
grDevices, grid, gridExtra, pscl, stats, survival, tibble
Suggests: broom, devtools, knitr, markdown, MASS, mice
VignetteBuilder: knitr
Encoding: UTF-8
Language: en-US
LazyData: true
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
NeedsCompilation: no
Packaged: 2021-07-16 05:11:12 UTC; akeil
Packaged: 2021-12-12 16:40:15 UTC; akeil
Repository: CRAN
Date/Publication: 2021-07-16 05:30:02 UTC
Date/Publication: 2021-12-12 17:20:02 UTC
44 changes: 22 additions & 22 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
ea0907dd8d8bf0253dbeee55a4ef41ac *DESCRIPTION
b6afd953f51f1073a6caf1c5b4228b0a *DESCRIPTION
45b94bbaaed7650e00a75f4dd64263ab *NAMESPACE
72211dc027952d22b7234f76983988d6 *NEWS.md
b0578a2fafc1900ec78e1a12197c7fb3 *R/base.R
45a9e6e780256018a5dbca48d618d380 *NEWS.md
a97b917ce3e1d74e4f7e04451f01f9bb *R/base.R
7bb09da9bf7f3d5610f6f4d8854ffc15 *R/base_bounds.R
ad02dc8706a119714c07e79b625cc3c5 *R/base_experimental.R
0864472a76fb326a0384aebcf5debb6e *R/base_extensions.R
ce715f03b6d7b17f17644b84e9b3c747 *R/base_generics.R
9afb7640c5aa4f7f62b797906a77b69e *R/base_hurdle.R
a2ec4b87648a50dbcf983a7418c01d6d *R/base_generics.R
1e7d87f01647c3a449e00a4b49a03d83 *R/base_hurdle.R
48dcec918baba27637817e8e9c157e7e *R/base_plots.R
9c350212698df84906f888384afa314c *R/base_samplesplits.R
3d883410bf8ee1ce5493c3470a37792a *R/base_simhelpers.R
5f9e610e1a041a46ab3acb05138a8699 *R/base_surv.R
8c822958f5f73b7c02bfea863709251f *R/base_utility.R
97497e491cdd6cfd510859cd1a1de3a6 *R/base_zi.R
c1010c23e7a3ff99d466b057d7a03ea7 *R/data.R
08c5cf7c518fd7e9f289d8517ab2535b *README.md
cc39b8f0f4f849f87f442e4003561109 *build/vignette.rds
f1ba7eb98effce3834743d0d94c10ce1 *R/base_surv.R
c140b5c60f253c3651016aa3f5af5ca0 *R/base_utility.R
2438f922c307df5aa315664442190186 *R/base_zi.R
daf60f4a2a0ea425235870c7988de990 *R/data.R
c6010d73c541566f61b6c5eb7b291cc9 *README.md
88d4e09aa6fa6930befc110a511d079c *build/vignette.rds
c52baf72a0ded2860f1fc7bcc0a44587 *data/metals.RData
d4606c509dc71895eb141f340de0ec41 *inst/doc/qgcomp-vignette.R
be2718a92a2cd546d7d7197fa12c406a *inst/doc/qgcomp-vignette.Rmd
bc2aadc9beed1205b96ed4ed153ec66b *inst/doc/qgcomp-vignette.html
d9d367fdeeccbc78a57d67bb0bacfdeb *inst/doc/qgcomp-vignette.R
40b9e2cdd5cbc36fd96d19d1b51a6004 *inst/doc/qgcomp-vignette.Rmd
90da432a06376c82f56483b3d5bdef73 *inst/doc/qgcomp-vignette.html
dcba3c6855f754b7494b841d285e3197 *inst/fig/fighex.png
d4f062a438e514faa03a0ae2c9f38a12 *inst/fig/fighex_social.png
a728173c2b39a9a95c900810feca0c26 *inst/fig/res1.png
Expand All @@ -32,7 +32,7 @@ aae600adc3ab853fb0e1ad835bc7bbd6 *inst/fig/res5.png
882b058937456f008fa1ed843cabea7c *man/glance.qgcompfit.Rd
8e8229ff4022716ab2f581007b4b8ab1 *man/hurdlemsm.fit.Rd
e8ce60028517f93774d710b3f1304b7e *man/hurdlemsm.fit.control.Rd
fe4d3e1f0eb95fff9501963f9c7f9b9a *man/metals.Rd
fb3a53ea7529ed58840a9dd391e16031 *man/metals.Rd
246ed51a262b533facebbba4f18b0894 *man/mice.impute.leftcenslognorm.Rd
d00e920bfd6bb988c6e9ab09b1d53d4b *man/modelbound.boot.Rd
b07ea7c4d35d3a68e4d6ce8241ad6510 *man/msm.fit.Rd
Expand All @@ -43,15 +43,15 @@ e03bf2686ec795d743c27e2eb16979e4 *man/msm.predict.Rd
be9635de94dc97e73cd42e4fe0bee060 *man/predict.qgcompfit.Rd
16e6bf82624318b907d18d714d6fa418 *man/print.qgcompfit.Rd
fc8955636f8d783a2a535db417402d13 *man/qgcomp.Rd
5fe305bf50bd9e80ad5bde30280641b6 *man/qgcomp.boot.Rd
8c056a34c46b1964cef0d1b857fd80cc *man/qgcomp.cox.boot.Rd
8584daf5f1542fdb28a88ccfc366ea81 *man/qgcomp.boot.Rd
73e7e074a52fabd27f4b16d6ed18d3bc *man/qgcomp.cox.boot.Rd
1e252c99b0270454f0da900ab76d0b90 *man/qgcomp.cox.noboot.Rd
5c87bfc251d53f7d2adcd7cd78c15fcf *man/qgcomp.hurdle.boot.Rd
5e68bc7f8be2aa7c643f2ca4f12441d1 *man/qgcomp.hurdle.boot.Rd
1418f7d295a1d046cd8e932b6b82f006 *man/qgcomp.hurdle.noboot.Rd
83d33c2554c16afe6960ed07bc16b255 *man/qgcomp.noboot.Rd
82c91b83d893c9fb3c920f3ac4be0502 *man/qgcomp.partials.Rd
754ef31f92fca5d8ff88e47d29e73cf8 *man/qgcomp.survcurve.boot.Rd
1eed0974da01dd7506b42d7d32f990d4 *man/qgcomp.zi.boot.Rd
7299dba0c2dac6a56b6faa9d1d08f78d *man/qgcomp.zi.boot.Rd
272ff788437b05b20ee98ba277f0e37f *man/qgcomp.zi.noboot.Rd
1f80778d431ea68be45ffbfd5b57263c *man/quantize.Rd
877cd72913f4eefc3f902c93d8db94d7 *man/se_comb.Rd
Expand All @@ -61,16 +61,16 @@ ce81e1ffbeb2e8f4d0ebda7b11e2156f *man/tidy.qgcompfit.Rd
adafbb49bfd55970000807640f274224 *man/vc_comb.Rd
21be15986a04cf91ac6c94d79806917b *man/zimsm.fit.Rd
fb7e649e05de6cc54a94061cf824942a *man/zimsm.fit.control.Rd
14f5ad5eb01480c666bd951c24e101aa *tests/test_asis.R
a5c483300a969c7486c668dd4ffc0255 *tests/test_asis.R
c7c524d4e7a45d818706709a57a6529d *tests/test_basics.R
4fe496ca8422555ef455b43f27240f77 *tests/test_bayesqgcomp.R
3adbce145f25a6436905f10c97898295 *tests/test_boot_ints.R
74219b40d4fb44b4eb414e9d0f45b018 *tests/test_bootchooser.R
01f20ca185dbcc7a95a366fca634ffcc *tests/test_bootchooser.R
2adc75ff8664eea0314992fd19ebff78 *tests/test_factor.R
3ecea9330c4be292acaed8d39ae81c87 *tests/test_id.R
5e757e8b3ebaa84f6f0dc3b3f78ebb38 *tests/test_mice.R
20abdeb552c2efed1352526d2baf8c88 *tests/test_numeric.R
1132ffeaf05f6fe7b409e9049f826bf2 *tests/test_poisson.R
34309c92ce57d4598adf623550be8cb5 *tests/test_splits.R
055d4f8d4b83a240f614fb268ffb5dbe *tests/test_weights.R
be2718a92a2cd546d7d7197fa12c406a *vignettes/qgcomp-vignette.Rmd
40b9e2cdd5cbc36fd96d19d1b51a6004 *vignettes/qgcomp-vignette.Rmd
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# qgcomp v2.8.5
## Major changes
- None

## Minor changes
- Handling of parallel processing through futures: bringing in line with package recommendations and planned deprecations.
- Documentation changes

# qgcomp v2.8.0
## Major changes
- Exposed simulation functions to the user
Expand Down
13 changes: 7 additions & 6 deletions R/base.R
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ qgcomp.noboot <- function(f,
res$zstat <- tstat
res$pval <- pvalz
}
#attr(res, "class") <- "qgcompfit"
res
}

Expand Down Expand Up @@ -458,7 +457,7 @@ qgcomp.boot <- function(
#' error at a given value of MCsize). This likely won't matter much in linear models, but may
#' be important with binary or count outcomes.
#' @param parallel use (safe) parallel processing from the future and future.apply packages
#' @param parplan (logical, default=FALSE) automatically set future::plan to plan(multiprocess) (and set to plan(invisible) after bootstrapping)
#' @param parplan (logical, default=FALSE) automatically set future::plan to plan(multisession) (and set to existing plan, if any, after bootstrapping)
#' @param ... arguments to glm (e.g. family)
#' @seealso \code{\link[qgcomp]{qgcomp.noboot}}, and \code{\link[qgcomp]{qgcomp}}
#' @return a qgcompfit object, which contains information about the effect
Expand Down Expand Up @@ -551,7 +550,7 @@ qgcomp.boot <- function(
#'
#' qgcomp.boot(y ~ z + x1iqr + I(x2iqr>0.1) + I(x2>0.4) + I(x2>0.9),
#' family="binomial", expnms = c('x1iqr', 'x2iqr'), data=dat, q=NULL, rr=TRUE, B=200,
#' degree=2, parallel=TRUE)
#' degree=2, parallel=TRUE, parplan=TRUE)
#'
#'
#' # weighted model
Expand Down Expand Up @@ -691,14 +690,17 @@ qgcomp.boot <- function(
set.seed(seed)
if(parallel){
#Sys.setenv(R_FUTURE_SUPPORTSMULTICORE_UNSTABLE="quiet")
if(parplan) future::plan(strategy = future::multisession)
if (parplan) {
oplan <- future::plan(strategy = future::multisession)
on.exit(future::plan(oplan), add = TRUE)
}
bootsamps <- future.apply::future_lapply(X=seq_len(B), FUN=psi.only,f=f, qdata=qdata, intvals=intvals,
expnms=expnms, rr=rr, degree=degree, nids=nids, id=id,
weights=qdata$weights,MCsize=MCsize, hasintercept = hasintercept,
future.seed=TRUE,
...)

if(parplan) future::plan(strategy = future::transparent)

}else{
bootsamps <- lapply(X=seq_len(B), FUN=psi.only,f=f, qdata=qdata, intvals=intvals,
expnms=expnms, rr=rr, degree=degree, nids=nids, id=id,
Expand Down Expand Up @@ -755,7 +757,6 @@ qgcomp.boot <- function(
res$zstat <- tstat
res$pval <- pvalz
}
attr(res, "class") <- "qgcompfit"
res
}

Expand Down
2 changes: 1 addition & 1 deletion R/base_generics.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ summary.qgcompfit <- function(object, ...){
colnames(pdat)[which(colnames(pdat)=="test")] = eval(paste(testtype, "value"))
colnames(pdat)[which(colnames(pdat)=="pval")] = eval(paste(plab))
rownames(pdat) <- rnm
list(coefficents=pdat)
list(coefficients=pdat)
}

family.qgcompfit <- function(object, ...){
Expand Down
13 changes: 8 additions & 5 deletions R/base_hurdle.R
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ qgcomp.hurdle.boot <- function(
#' linear fits with qgcomp.hurdle.noboot to gain some intuition for the level of expected simulation
#' error at a given value of MCsize)
#' @param msmcontrol named list from \code{\link[qgcomp]{hurdlemsm.fit.control}}
#' @param parplan (logical, default=FALSE) automatically set future::plan to plan(multiprocess) (and set to plan(invisible) after bootstrapping)
#' @param parplan (logical, default=FALSE) automatically set future::plan to plan(multisession) (and set to existing plan, if any, after bootstrapping)
#' @param ... arguments to glm (e.g. family)
#' @seealso \code{\link[qgcomp]{qgcomp.hurdle.noboot}},\code{\link[qgcomp]{qgcomp.boot}},
#' \code{\link[qgcomp]{qgcomp.cox.boot}}, and \code{\link[pscl]{hurdle}}
Expand All @@ -511,15 +511,15 @@ qgcomp.hurdle.boot <- function(
#' \dontrun{
#' # warning: the examples below can take a long time to run
#' res = qgcomp.hurdle.boot(f=y ~ x1 + x2 | x1 + x2, expnms = c('x1', 'x2'),
#' data=dat, q=4, dist="poisson", B=1000, MCsize=10000, parallel=TRUE)
#' data=dat, q=4, dist="poisson", B=1000, MCsize=10000, parallel=TRUE, parplan=TRUE)
#' qgcomp.hurdle.noboot(f=y ~ x1 + x2 | x1 + x2, expnms = c('x1', 'x2'),
#' data=dat, q=4, dist="poisson")
#' res
#'
#' # accuracy for small MCsize is suspect (compare coefficients between boot/noboot versions),
#' # so re-check with MCsize set to larger value (this takes a long time to run)
#' res2 = qgcomp.hurdle.boot(f=y ~ x1 + x2 | x1 + x2, expnms = c('x1', 'x2'),
#' data=dat, q=4, dist="poisson", B=1000, MCsize=50000, parallel=TRUE)
#' data=dat, q=4, dist="poisson", B=1000, MCsize=50000, parallel=TRUE, parplan=TRUE)
#' res2
#' plot(density(res2$bootsamps[4,]))
#'
Expand Down Expand Up @@ -672,7 +672,10 @@ qgcomp.hurdle.boot <- function(
set.seed(seed)
if(parallel){
#Sys.setenv(R_FUTURE_SUPPORTSMULTICORE_UNSTABLE="quiet")
if(parplan) future::plan(strategy = future::multisession)
if (parplan) {
oplan <- future::plan(strategy = future::multisession)
on.exit(future::plan(oplan), add = TRUE)
}
#testenv <- list2env(list(qdata=qdata, weights=weights))
bootsamps <- future.apply::future_lapply(X=seq_len(B), FUN=psi.only,f=newform, qdata=qdata, intvals=intvals,
expnms=expnms, degree=degree, nids=nids, id=id,
Expand All @@ -681,7 +684,7 @@ qgcomp.hurdle.boot <- function(
future.seed=TRUE,
...)

if(parplan) future::plan(strategy = future::transparent)

}else{
bootsamps <- lapply(X=seq_len(B), FUN=psi.only,f=newform, qdata=qdata, intvals=intvals,
expnms=expnms, degree=degree, nids=nids, id=id,
Expand Down
11 changes: 7 additions & 4 deletions R/base_surv.R
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ qgcomp.cox.boot <- function(f, data, expnms=NULL, q=4, breaks=NULL,
#' to 2 decimal places).
#' @param seed integer or NULL: random number seed for replicable bootstrap results
#' @param parallel logical (default FALSE): use future package to speed up bootstrapping
#' @param parplan (logical, default=FALSE) automatically set future::plan to plan(multiprocess) (and set to plan(invisible) after bootstrapping)
#' @param parplan (logical, default=FALSE) automatically set future::plan to plan(multisession) (and set to existing plan, if any, after bootstrapping)
#' @param ... arguments to glm (e.g. family)
#' @seealso \code{\link[qgcomp]{qgcomp.cox.noboot}}, and \code{\link[qgcomp]{qgcomp}}
#' @return a qgcompfit object, which contains information about the effect
Expand Down Expand Up @@ -517,7 +517,7 @@ qgcomp.cox.boot <- function(f, data, expnms=NULL, q=4, breaks=NULL,
#'
#' # using future package, marginalizing over confounder z
#' (obj3 <- qgcomp.cox.boot(survival::Surv(time, d)~x1 + x2 + z, expnms = expnms, data = dat,
#' B=1000, MCsize=20000, parallel=TRUE))
#' B=1000, MCsize=20000, parallel=TRUE, parplan=TRUE))
#' # non-constant hazard ratio, non-linear terms
#' (obj4 <- qgcomp.cox.boot(survival::Surv(time, d)~factor(x1) + splines::bs(x2) + z,
#' expnms = expnms, data = dat,
Expand Down Expand Up @@ -623,13 +623,16 @@ qgcomp.cox.boot <- function(f, data, expnms=NULL, q=4, breaks=NULL,
set.seed(seed)
if(parallel){
#Sys.setenv(R_FUTURE_SUPPORTSMULTICORE_UNSTABLE="quiet")
if(parplan) future::plan(strategy = future::multisession)
if (parplan) {
oplan <- future::plan(strategy = future::multisession)
on.exit(future::plan(oplan), add = TRUE)
}
bootsamps <- future.apply::future_lapply(X=seq_len(B), FUN=psi.only,
f=newform, qdata=qdata, intvals=intvals,
expnms=expnms, degree=degree, nids=nids, id=id,
future.seed=TRUE,
weights=qdata$weights, MCsize=MCsize, ...)
if(parplan) future::plan(strategy = future::transparent)

}else {
bootsamps <- lapply(X=seq_len(B), FUN=psi.only,
f=newform, qdata=qdata, intvals=intvals,
Expand Down
2 changes: 1 addition & 1 deletion R/base_utility.R
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ checknames <- function(terms){
if(is.na(match("pos.size", nms))) res$pos.size = NULL
if(is.na(match("neg.size", nms))) res$neg.size = NULL
if(is.na(match("df", nms))) res$df = NULL
attr(res, "class") <- c("list", "qgcompfit")
attr(res, "class") <- c("qgcompfit", "list")
res
}

13 changes: 8 additions & 5 deletions R/base_zi.R
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ qgcomp.zi.boot <- function(f,
#' linear fits with qgcomp.zi.noboot to gain some intuition for the level of expected simulation
#' error at a given value of MCsize)
#' @param msmcontrol named list from \code{\link[qgcomp]{zimsm.fit.control}}
#' @param parplan (logical, default=FALSE) automatically set future::plan to plan(multiprocess) (and set to plan(invisible) after bootstrapping)
#' @param parplan (logical, default=FALSE) automatically set future::plan to plan(multisession) (and set to existing plan, if any, after bootstrapping)
#' @param ... arguments to glm (e.g. family)
#' @seealso \code{\link[qgcomp]{qgcomp.zi.noboot}},\code{\link[qgcomp]{qgcomp.boot}},
#' \code{\link[qgcomp]{qgcomp.cox.boot}}, and \code{\link[pscl]{zeroinfl}}
Expand All @@ -501,15 +501,15 @@ qgcomp.zi.boot <- function(f,
#' \dontrun{
#' # warning: the examples below can take a long time to run
#' res = qgcomp.zi.boot(f=y ~ x1 + x2 | x1 + x2, expnms = c('x1', 'x2'),
#' data=dat, q=4, dist="poisson", B=1000, MCsize=10000, parallel=TRUE)
#' data=dat, q=4, dist="poisson", B=1000, MCsize=10000, parallel=TRUE, parplan=TRUE)
#' qgcomp.zi.noboot(f=y ~ x1 + x2 | x1 + x2, expnms = c('x1', 'x2'),
#' data=dat, q=4, dist="poisson")
#' res
#'
#' # accuracy for small MCsize is suspect (compare coefficients between boot/noboot versions),
#' # so re-check with MCsize set to larger value (this takes a long time to run)
#' res2 = qgcomp.zi.boot(f=y ~ x1 + x2 | x1 + x2, expnms = c('x1', 'x2'),
#' data=dat, q=4, dist="poisson", B=1000, MCsize=50000, parallel=TRUE)
#' data=dat, q=4, dist="poisson", B=1000, MCsize=50000, parallel=TRUE, parplan=TRUE)
#' res2
#' plot(density(res2$bootsamps[4,]))
#'
Expand Down Expand Up @@ -665,7 +665,10 @@ qgcomp.zi.boot <- function(f,
set.seed(seed)
if(parallel){
#Sys.setenv(R_FUTURE_SUPPORTSMULTICORE_UNSTABLE="quiet")
if(parplan) future::plan(strategy = future::multisession)
if (parplan) {
oplan <- future::plan(strategy = future::multisession)
on.exit(future::plan(oplan), add = TRUE)
}
#testenv <- list2env(list(qdata=qdata, weights=weights))
bootsamps <- future.apply::future_lapply(X=seq_len(B), FUN=psi.only,f=newform, qdata=qdata, intvals=intvals,
expnms=expnms, degree=degree, nids=nids, id=id,
Expand All @@ -674,7 +677,7 @@ qgcomp.zi.boot <- function(f,
future.seed=TRUE,
...)

if(parplan) future::plan(strategy = future::transparent)

}else{
bootsamps <- lapply(X=seq_len(B), FUN=psi.only,f=newform, qdata=qdata, intvals=intvals,
expnms=expnms, degree=degree, nids=nids, id=id,
Expand Down
2 changes: 1 addition & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#'
#' A dataset containing well water measurements and health outcomes for 253 individuals.
#' All continuous variables are standardized to have mean 0, standard deviation 1.
#'
#' @usage data(metals)
#' @format A data frame with 253 rows and 24 variables:
#' \describe{
#' \item{y}{continuous birth outcome}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
`qgcomp` v2.8.0
`qgcomp` v2.8.5



Expand Down
Binary file modified build/vignette.rds
Binary file not shown.
Loading

0 comments on commit 46f062f

Please sign in to comment.