R Under development (unstable) (2023-08-08 r84908 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > cat("# boot chooser test\n") # boot chooser test > library("qgcomp") > library("splines") > library("survival") > > dgm <- function(N){ + dat <- data.frame(id=1:N) + dat <- within(dat, { + time=(tmg <- pmin(.1,rweibull(N, 10, 0.1))) + d=1.0*(tmg<0.1) + u = 0 + x1 = runif(N)*4 + u + x2 = runif(N)*4 + u + x3 = runif(N)*4 + u + x4 = runif(N)*4 + u + x5 = runif(N)*4 + u + x6 = runif(N)*4 + u + y = rnorm(N, x1+x2, 2) + }) + dat[,c("y", "time", "d", paste0("x", 1:6))] + } > > set.seed(11232) > dat = dgm(100) > Xnm = c(paste0("x", 1:6)) > > > f = y~x1 + x2 + x3 + I(x3^2) > qgcomp(f, expnms = c("x1", "x2"), data = dat) Mixture slope parameters (bootstrap CI): Estimate Std. Error Lower CI Upper CI t value Pr(>|t|) (Intercept) 0.11343 0.42902 -0.72744 0.95429 0.2644 0.7921 psi1 2.55385 0.24111 2.08129 3.02641 10.5921 <2e-16 > qgcomp.noboot(f, expnms = c("x1", "x2"), data = dat) Scaled effect size (positive direction, sum of positive coefficients = 2.55) x1 x2 0.508 0.492 Scaled effect size (negative direction, sum of negative coefficients = 0) None Mixture slope parameters (Delta method CI): Estimate Std. Error Lower CI Upper CI t value Pr(>|t|) (Intercept) 0.35877 0.72969 -1.0714 1.7889 0.4917 0.6241 psi1 2.55385 0.25209 2.0598 3.0479 10.1308 <2e-16 > > > > # should cause errors > f = y~. + .^2 > res = try(qgcomp(f, data = dat), silent=TRUE) Including all model terms as exposures of interest > stopifnot(class(res)=="try-error") > > fs = Surv(time,d)~. + .^2 > res = try(qgcomp(fs, data = dat), silent=TRUE) Including all model terms as exposures of interest > stopifnot(class(res)=="try-error") > > > f = y~. > res = try(fit1 <- qgcomp(f, expnms=Xnm, data = dat, parallel=TRUE), silent=TRUE) > stopifnot(class(res)=="try-error") > > fs = Surv(time,d)~. > res = try(fit1 <- qgcomp(fs, expnms=Xnm, data = dat, B=5, MCsize=100), silent=TRUE) > stopifnot(class(res)=="try-error") > > fs = Surv(time,d)~. > res = try(fit1 <- qgcomp(fs, expnms=Xnm, family=cox(), data = dat), silent=TRUE) > stopifnot(class(res)=="try-error") > > #' \dontrun{ > #' f = y~. + .^2 > #' res = try(fit1 <- qgcomp(f, expnms=Xnm, data = dat), silent=TRUE) > #' stopifnot(inherits(res,"qgcompfit")) > #' > #' fs = Surv(time,d)~. + .^2 > #' res = try(fit1 <- qgcomp(fs, expnms=Xnm, data = dat, B=5, MCsize=100), silent=TRUE) > #' stopifnot(inherits(res,"qgcompfit")) > #' > #' fs = Surv(time,d)~. + .^2 > #' res = try(fit1 <- qgcomp(fs, expnms=Xnm, data = dat, B=5, MCsize=100, parallel=TRUE), silent=TRUE) > #' stopifnot(inherits(res,"qgcompfit")) > #' > #' > #' > #' # splines splines do work > #' f = y ~ x2 + x3 + x4 + x5 + x6 + splines::ns(x1, df=2) > #' res = try(qgcomp(f, data = dat), silent=TRUE) > #' stopifnot(class(res)=="try-error") # should give error that expnms not defined > #' res = try(fit1 <- qgcomp(f, expnms=Xnm, q=8, data = dat, deg=2), silent=TRUE) > #' stopifnot(inherits(res,"qgcompfit")) > #' > #' > #' > #' # splines splines do work > #' f = y ~ x2 + x3 + x4 + x5 + x6 + splines::ns(x1, df=2) > #' res = try(qgcomp(f, data = dat), silent=TRUE) > #' stopifnot(class(res)=="try-error") # should give error that expnms not defined > #' res = try(fit1 <- qgcomp(f, expnms=Xnm, q=8, data = dat, deg=2), silent=TRUE) > #' stopifnot(inherits(res,"qgcompfit")) > #' > #' # splines splines + bayes > #' f = y ~ x2 + x3 + x4 + x5 + x6 + splines::ns(x1, df=2) > #' res = try(fit2 <- qgcomp(f, expnms=Xnm, q=8, data = dat, deg=2, bayes=TRUE), silent=TRUE) > #' stopifnot(inherits(res,"qgcompfit")) > #' > #' > #' # indicator functions > #' f = y ~ factor(x1) + x2 + x3 + x4 + x5 + x6 > #' res = try(qgcomp(f, data = dat), silent=TRUE) > #' stopifnot(class(res)=="try-error") # should give error that expnms not defined > #' res = try(fit1 <- qgcomp(f, expnms=Xnm, q=8, data = dat, deg=3), silent=TRUE) > #' stopifnot(inherits(res,"qgcompfit")) > #' } > > > cat("done") done> > proc.time() user system elapsed 5.39 0.40 5.78