==2490768== Memcheck, a memory error detector ==2490768== Copyright (C) 2002-2026, and GNU GPL'd, by Julian Seward et al. ==2490768== Using Valgrind-3.27.1 and LibVEX; rerun with -h for copyright info ==2490768== Command: /data/localhost/ripley/R/R-devel-vg/bin/exec/R --vanilla ==2490768== R Under development (unstable) (2026-07-27 r90310) -- "Unsuffered Consequences" Copyright (C) 2026 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu 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. Natural language support but running in an English locale 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. > pkgname <- "carat" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('carat') > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') > cleanEx() > nameEx("AdjBCD") > ### * AdjBCD > > flush(stderr()); flush(stdout()) > > ### Name: AdjBCD > ### Title: Covariate-adjusted Biased Coin Design > ### Aliases: AdjBCD > ### Keywords: carandom Covariate-ajusted biased coin design > > ### ** Examples > > # a simple use > ## Real Data > ## create a dataframe > df <- data.frame("gender" = sample(c("female", "male"), 1000, TRUE, c(1 / 3, 2 / 3)), + "age" = sample(c("0-30", "30-50", ">50"), 1000, TRUE), + "jobs" = sample(c("stu.", "teac.", "others"), 1000, TRUE), + stringsAsFactors = TRUE) > Res <- AdjBCD(df, a = 2) > ## view the output > Res Covariate-adaptive Biased Coin Design Data: Real group = A B Sample size = 1000 cov_num = 3 considered covariates: gender age jobs level_num = 2 3 3 the first three patients' covariate-profiles and assignments: covariate1 covariate2 covariate3 assignment pat1 1 1 1 B pat2 1 1 2 B pat3 1 2 2 A Mean absolute imbalances at overall, within-strt., and within-cov.-margin levels: overall within-strt. within-cov.-margin 0.000 1.111 2.750 Remark-Index: 1 -- gender 1 <--> male; 2 <--> female 2 -- age 1 <--> >50; 2 <--> 0-30; 3 <--> 30-50 3 -- jobs 1 <--> teac.; 2 <--> others; 3 <--> stu. > > ## Simulated Data > n <- 1000 > cov_num <- 3 > level_num <- c(2, 3, 5) > # Set pr to follow two tips: > #(1) length of pr should be sum(level_num); > #(2) sum of probabilities for each margin should be 1. > pr <- c(0.4, 0.6, 0.3, 0.4, 0.3, rep(0.2, times = 5)) > # set the design parameter > a <- 1.8 > # obtain result > Res.sim <- AdjBCD.sim(n, cov_num, level_num, pr, a) > > > > cleanEx() > nameEx("CompPower") > ### * CompPower > > flush(stderr()); flush(stdout()) > > ### Name: compPower > ### Title: Comparison of Powers for Different Tests under Different > ### Randomization methods > ### Aliases: compPower > > ### ** Examples > > ##settings > set.seed(100) > n = 1000 > cov_num = 5 > level_num = c(2,2,2,2,2) > pr = rep(0.5,10) > beta = c(1,4,3,2,5,5,4,3,2,1) > di = seq(0,0.5,0.1) > sigma = 1 > type = "linear" > p=0.85 > Iternum = 10 #< sl = 0.05 > weight = rep(0.1,5) > > #comparison of corrected t-test under StrBCD and PocSim > ##data generation > library("ggplot2") > Strctp=evalPower(n,cov_num,level_num,pr,type,beta,di, + sigma,Iternum,sl,"StrBCD","corr.test",FALSE,p) > PSctp=evalPower(n,cov_num,level_num,pr,type,beta,di,sigma, + Iternum,sl,"PocSimMIN","corr.test",FALSE,weight,p) > powers = list(Strctp,PSctp) > testname = c("StrBCD.corr","PocSimMIN.corr") > > #get plot and matrix for comparison > cp = compPower(powers,di,testname) > cp $powers 0 0.1 0.2 0.3 0.4 0.5 StrBCD.corr 0.2(0.126) 0.1(0.095) 0.9(0.095) 1(0) 1(0) 1(0) PocSimMIN.corr 0(0) 0.4(0.155) 1(0) 1(0) 1(0) 1(0) $plot > > > > cleanEx() detaching ‘package:ggplot2’ > nameEx("DoptBCD") > ### * DoptBCD > > flush(stderr()); flush(stdout()) > > ### Name: DoptBCD > ### Title: Atkinson's D_A-optimal Biased Coin Design > ### Aliases: DoptBCD > > ### ** Examples > > # a simple use > ## Real Data > df <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), + "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), + "jobs" = sample(c("stu.", "teac.", "others"), 100, TRUE), + stringsAsFactors = TRUE) > Res <- DoptBCD(df) > ## view the output > Res Atkinson's Optimum Biased Coin Design Data: Real group = A B Sample size = 100 cov_num = 3 considered covariates: gender age jobs level_num = 2 3 3 the first three patients' covariate-profiles and assignments: covariate1 covariate2 covariate3 assignment pat1 1 1 1 B pat2 1 1 1 A pat3 1 1 2 A Mean absolute imbalances at overall, within-strt., and within-cov.-margin levels: overall within-strt. within-cov.-margin 2.000 2.222 2.250 Remark-Index: 1 -- gender 1 <--> male; 2 <--> female 2 -- age 1 <--> 0-30; 2 <--> >50; 3 <--> 30-50 3 -- jobs 1 <--> others; 2 <--> stu.; 3 <--> teac. > > ## Simulated Data > n <- 1000 > cov_num <- 2 > > level_num <- c(2, 5) > # Set pr to follow two tips: > #(1) length of pr should be sum(level_num); > #(2)sum of probabilities for each margin should be 1. > pr <- c(0.4, 0.6, rep(0.2, times = 5)) > Res.sim <- DoptBCD.sim(n, cov_num, level_num, pr) > ## view the output > Res.sim Atkinson's Optimum Biased Coin Design with Two Arms Data: Simulated group = A B Sample size = 1000 cov_num = 2 level_num = 2 5 the first three patients' covariate-profiles and assignments: covariate1 covariate2 assignment pat1 2 5 B pat2 1 1 A pat3 1 3 A Mean absolute imbalances at overall, within-strt., and within-cov.-margin levels: overall within-strt. within-cov.-margin 6.000 8.800 7.143 > > > > > cleanEx() > nameEx("HuHuCAR") > ### * HuHuCAR > > flush(stderr()); flush(stdout()) > > ### Name: HuHuCAR > ### Title: Hu and Hu's General Covariate-Adaptive Randomization > ### Aliases: HuHuCAR > > ### ** Examples > > # a simple use > ## Real Data > ## create a dataframe > df <- data.frame("gender" = sample(c("female", "male"), 1000, TRUE, c(1 / 3, 2 / 3)), + "age" = sample(c("0-30", "30-50", ">50"), 1000, TRUE), + "jobs" = sample(c("stu.", "teac.", "others"), 1000, TRUE), + stringsAsFactors = TRUE) > omega <- c(1, 2, rep(1, 3)) > Res <- HuHuCAR(data = df, omega) > ## view the output > Res Hu and Hu's General CAR Data: Real group = A B Sample size = 1000 cov_num = 3 considered covariates: gender age jobs level_num = 2 3 3 the first three patients' covariate-profiles and assignments: covariate1 covariate2 covariate3 assignment pat1 1 1 1 B pat2 1 1 2 A pat3 1 2 2 B Mean absolute imbalances at overall, within-strt., and within-cov.-margin levels: overall within-strt. within-cov.-margin 0 1 1 Remark-Index: 1 -- gender 1 <--> male; 2 <--> female 2 -- age 1 <--> >50; 2 <--> 0-30; 3 <--> 30-50 3 -- jobs 1 <--> teac.; 2 <--> others; 3 <--> stu. > > ## Simulated data > cov_num <- 3 > level_num <- c(2, 3, 3) > pr <- c(0.4, 0.6, 0.3, 0.4, 0.3, 0.4, 0.3, 0.3) > omega <- rep(0.2, times = 5) > Res.sim <- HuHuCAR.sim(n = 100, cov_num, level_num, pr, omega) > ## view the output > Res.sim Hu and Hu's General CAR Data: Simulated group = A B Sample size = 100 cov_num = 3 level_num = 2 3 3 the first three patients' covariate-profiles and assignments: covariate1 covariate2 covariate3 assignment pat1 2 2 2 B pat2 1 2 1 A pat3 1 1 2 B Mean absolute imbalances at overall, within-strt., and within-cov.-margin levels: overall within-strt. within-cov.-margin 0.00 1.00 0.75 > > > > > cleanEx() > nameEx("PocSimMIN") > ### * PocSimMIN > > flush(stderr()); flush(stdout()) > > ### Name: PocSimMIN > ### Title: Pocock and Simon's Method in the Two-Arms Case > ### Aliases: PocSimMIN > > ### ** Examples > > # a simple use > ## Real Data > ## creat a dataframe > df <- data.frame("gender" = sample(c("female", "male"), 1000, TRUE, c(1 / 3, 2 / 3)), + "age" = sample(c("0-30", "30-50", ">50"), 1000, TRUE), + "jobs" = sample(c("stu.", "teac.", "others"), 1000, TRUE), + stringsAsFactors = TRUE) > weight <- c(1, 2, 1) > Res <- PocSimMIN(data = df, weight) > ## view the output > Res Pocock and Simon's Procedure with Two Arms Data: Real group = A B Sample size = 1000 cov_num = 3 considered covariates: gender age jobs level_num = 2 3 3 the first three patients' covariate-profiles and assignments: covariate1 covariate2 covariate3 assignment pat1 1 1 1 B pat2 1 1 2 A pat3 1 2 2 B Mean absolute imbalances at overall, within-strt., and within-cov.-margin levels: overall within-strt. within-cov.-margin 0.000 4.111 1.250 Remark-Index: 1 -- gender 1 <--> male; 2 <--> female 2 -- age 1 <--> >50; 2 <--> 0-30; 3 <--> 30-50 3 -- jobs 1 <--> teac.; 2 <--> others; 3 <--> stu. > > ## Simulated Data > cov_num = 3 > level_num = c(2, 3, 3) > pr = c(0.4, 0.6, 0.3, 0.3, 0.4, 0.4, 0.3, 0.3) > Res.sim <- PocSimMIN.sim(n = 1000, cov_num, level_num, pr) > ## view the output > Res.sim Pocock and Simon's Procedure with Two Arms Data: Simulated group = A B Sample size = 1000 cov_num = 3 level_num = 2 3 3 the first three patients' covariate-profiles and assignments: covariate1 covariate2 covariate3 assignment pat1 2 3 2 B pat2 1 1 3 A pat3 1 3 2 A Mean absolute imbalances at overall, within-strt., and within-cov.-margin levels: overall within-strt. within-cov.-margin 2.000 5.667 0.750 > > > > > cleanEx() > nameEx("StrBCD") > ### * StrBCD > > flush(stderr()); flush(stdout()) > > ### Name: StrBCD > ### Title: Shao's Method in the Two-Arms Case > ### Aliases: StrBCD > > ### ** Examples > > # a simple use > ## Real Data > ## creat a dataframe > df <- data.frame("gender" = sample(c("female", "male"), 1000, TRUE, c(1 / 3, 2 / 3)), + "age" = sample(c("0-30", "30-50", ">50"), 1000, TRUE), + "jobs" = sample(c("stu.", "teac.", "others"), 1000, TRUE), + stringsAsFactors = TRUE) > Res <- StrBCD(data = df) > ## view the output > Res Shao's Procedure Data: Real group = A B Sample size = 1000 cov_num = 3 considered covariates: gender age jobs level_num = 2 3 3 the first three patients' covariate-profiles and assignments: covariate1 covariate2 covariate3 assignment pat1 1 1 1 B pat2 1 1 2 B pat3 1 2 2 A Mean absolute imbalances at overall, within-strt., and within-cov.-margin levels: overall within-strt. within-cov.-margin 0.0000 0.6667 1.0000 Remark-Index: 1 -- gender 1 <--> male; 2 <--> female 2 -- age 1 <--> >50; 2 <--> 0-30; 3 <--> 30-50 3 -- jobs 1 <--> teac.; 2 <--> others; 3 <--> stu. > > ## Simulated Data > cov_num = 3 > level_num = c(2, 3, 3) > pr = c(0.4, 0.6, 0.3, 0.4, 0.3, 0.4, 0.3, 0.3) > Res.sim <- StrBCD.sim(n = 1000, cov_num, level_num, pr) > ## view the output > Res.sim Shao's Procedure Data: Simulated group = A B Sample size = 1000 cov_num = 3 level_num = 2 3 3 the first three patients' covariate-profiles and assignments: covariate1 covariate2 covariate3 assignment pat1 2 3 2 B pat2 1 1 3 A pat3 1 2 2 A Mean absolute imbalances at overall, within-strt., and within-cov.-margin levels: overall within-strt. within-cov.-margin 0.0000 0.7778 1.7500 > > > > > cleanEx() > nameEx("StrPBR") > ### * StrPBR > > flush(stderr()); flush(stdout()) > > ### Name: StrPBR > ### Title: Stratified Permuted Block Randomization > ### Aliases: StrPBR > > ### ** Examples > > # a simple use > ## Real Data > ## creat a dataframe > df <- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), + "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), + "jobs" = sample(c("stu.", "teac.", "others"), 100, TRUE), + stringsAsFactors = TRUE) > Res <- StrPBR(data = df, bsize = 4) ==2490768== Invalid read of size 8 ==2490768== at 0x53A83E: STRING_ELT (/data/localhost/ripley/R/svn/R-devel/src/include/Rinlinedfuns.h:480) ==2490768== by 0x53A83E: do_paste (/data/localhost/ripley/R/svn/R-devel/src/main/paste.c:196) ==2490768== by 0x4D92DD: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8150) ==2490768== by 0x4E4461: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533) ==2490768== by 0x4E4461: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518) ==2490768== by 0x4E482A: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167) ==2490768== by 0x4E66C6: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398) ==2490768== by 0x4E746F: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314) ==2490768== by 0x4E4A38: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333) ==2490768== by 0x4E4A38: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278) ==2490768== by 0x47EAE0: R_UnwindProtect (/data/localhost/ripley/R/svn/R-devel/src/main/context.c:984) ==2490768== by 0x1C18FA04: Rcpp::unwindProtect(SEXPREC* (*)(void*), void*) (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/unwindProtect.h:68) ==2490768== by 0x1C1938B1: Rcpp_fast_eval (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/api/meat/Rcpp_eval.h:51) ==2490768== by 0x1C1938B1: Rcpp::Function_Impl::invoke(SEXPREC*, SEXPREC*) const (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/Function.h:138) ==2490768== by 0x1C148EEF: operator() > (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/Function.h:100) ==2490768== by 0x1C148EEF: nameString(unsigned int, arma::Col, int, Rcpp::String, arma::Mat) (/data/localhost/ripley/R/packages/tests-vg/carat/src/InnerFun.cpp:252) ==2490768== by 0x1C1A5615: _carat_nameString (/data/localhost/ripley/R/packages/tests-vg/carat/src/RcppExports.cpp:97) ==2490768== Address 0x1c27cd28 is 4,984 bytes inside a block of size 7,960 alloc'd ==2490768== at 0x4840AE6: malloc (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:447) ==2490768== by 0x529A79: GetNewPage (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:998) ==2490768== by 0x52BAF3: Rf_allocVector3 (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:2872) ==2490768== by 0x53A76C: Rf_allocVector (/data/localhost/ripley/R/svn/R-devel/src/include/Rinlinedfuns.h:609) ==2490768== by 0x53A76C: do_paste (/data/localhost/ripley/R/svn/R-devel/src/main/paste.c:174) ==2490768== by 0x4D92DD: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8150) ==2490768== by 0x4E4461: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533) ==2490768== by 0x4E4461: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518) ==2490768== by 0x4E482A: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167) ==2490768== by 0x4E66C6: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398) ==2490768== by 0x4E746F: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314) ==2490768== by 0x4E4A38: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333) ==2490768== by 0x4E4A38: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278) ==2490768== by 0x47EAE0: R_UnwindProtect (/data/localhost/ripley/R/svn/R-devel/src/main/context.c:984) ==2490768== by 0x1C18FA04: Rcpp::unwindProtect(SEXPREC* (*)(void*), void*) (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/unwindProtect.h:68) ==2490768== ==2490768== Invalid read of size 8 ==2490768== at 0x53A91E: STRING_ELT (/data/localhost/ripley/R/svn/R-devel/src/include/Rinlinedfuns.h:480) ==2490768== by 0x53A91E: do_paste (/data/localhost/ripley/R/svn/R-devel/src/main/paste.c:212) ==2490768== by 0x4D92DD: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8150) ==2490768== by 0x4E4461: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533) ==2490768== by 0x4E4461: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518) ==2490768== by 0x4E482A: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167) ==2490768== by 0x4E66C6: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398) ==2490768== by 0x4E746F: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314) ==2490768== by 0x4E4A38: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333) ==2490768== by 0x4E4A38: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278) ==2490768== by 0x47EAE0: R_UnwindProtect (/data/localhost/ripley/R/svn/R-devel/src/main/context.c:984) ==2490768== by 0x1C18FA04: Rcpp::unwindProtect(SEXPREC* (*)(void*), void*) (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/unwindProtect.h:68) ==2490768== by 0x1C1938B1: Rcpp_fast_eval (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/api/meat/Rcpp_eval.h:51) ==2490768== by 0x1C1938B1: Rcpp::Function_Impl::invoke(SEXPREC*, SEXPREC*) const (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/Function.h:138) ==2490768== by 0x1C148EEF: operator() > (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/Function.h:100) ==2490768== by 0x1C148EEF: nameString(unsigned int, arma::Col, int, Rcpp::String, arma::Mat) (/data/localhost/ripley/R/packages/tests-vg/carat/src/InnerFun.cpp:252) ==2490768== by 0x1C1A5615: _carat_nameString (/data/localhost/ripley/R/packages/tests-vg/carat/src/RcppExports.cpp:97) ==2490768== Address 0x1c27cd28 is 4,984 bytes inside a block of size 7,960 alloc'd ==2490768== at 0x4840AE6: malloc (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:447) ==2490768== by 0x529A79: GetNewPage (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:998) ==2490768== by 0x52BAF3: Rf_allocVector3 (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:2872) ==2490768== by 0x53A76C: Rf_allocVector (/data/localhost/ripley/R/svn/R-devel/src/include/Rinlinedfuns.h:609) ==2490768== by 0x53A76C: do_paste (/data/localhost/ripley/R/svn/R-devel/src/main/paste.c:174) ==2490768== by 0x4D92DD: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8150) ==2490768== by 0x4E4461: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533) ==2490768== by 0x4E4461: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518) ==2490768== by 0x4E482A: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167) ==2490768== by 0x4E66C6: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398) ==2490768== by 0x4E746F: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314) ==2490768== by 0x4E4A38: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333) ==2490768== by 0x4E4A38: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278) ==2490768== by 0x47EAE0: R_UnwindProtect (/data/localhost/ripley/R/svn/R-devel/src/main/context.c:984) ==2490768== by 0x1C18FA04: Rcpp::unwindProtect(SEXPREC* (*)(void*), void*) (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/unwindProtect.h:68) ==2490768== ==2490768== Invalid read of size 8 ==2490768== at 0x53AA47: STRING_ELT (/data/localhost/ripley/R/svn/R-devel/src/include/Rinlinedfuns.h:480) ==2490768== by 0x53AA47: do_paste (/data/localhost/ripley/R/svn/R-devel/src/main/paste.c:232) ==2490768== by 0x4D92DD: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8150) ==2490768== by 0x4E4461: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533) ==2490768== by 0x4E4461: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518) ==2490768== by 0x4E482A: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167) ==2490768== by 0x4E66C6: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398) ==2490768== by 0x4E746F: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314) ==2490768== by 0x4E4A38: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333) ==2490768== by 0x4E4A38: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278) ==2490768== by 0x47EAE0: R_UnwindProtect (/data/localhost/ripley/R/svn/R-devel/src/main/context.c:984) ==2490768== by 0x1C18FA04: Rcpp::unwindProtect(SEXPREC* (*)(void*), void*) (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/unwindProtect.h:68) ==2490768== by 0x1C1938B1: Rcpp_fast_eval (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/api/meat/Rcpp_eval.h:51) ==2490768== by 0x1C1938B1: Rcpp::Function_Impl::invoke(SEXPREC*, SEXPREC*) const (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/Function.h:138) ==2490768== by 0x1C148EEF: operator() > (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/Function.h:100) ==2490768== by 0x1C148EEF: nameString(unsigned int, arma::Col, int, Rcpp::String, arma::Mat) (/data/localhost/ripley/R/packages/tests-vg/carat/src/InnerFun.cpp:252) ==2490768== by 0x1C1A5615: _carat_nameString (/data/localhost/ripley/R/packages/tests-vg/carat/src/RcppExports.cpp:97) ==2490768== Address 0x1c27cd28 is 4,984 bytes inside a block of size 7,960 alloc'd ==2490768== at 0x4840AE6: malloc (/builddir/build/BUILD/valgrind-3.27.1-build/valgrind-3.27.1/coregrind/m_replacemalloc/vg_replace_malloc.c:447) ==2490768== by 0x529A79: GetNewPage (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:998) ==2490768== by 0x52BAF3: Rf_allocVector3 (/data/localhost/ripley/R/svn/R-devel/src/main/memory.c:2872) ==2490768== by 0x53A76C: Rf_allocVector (/data/localhost/ripley/R/svn/R-devel/src/include/Rinlinedfuns.h:609) ==2490768== by 0x53A76C: do_paste (/data/localhost/ripley/R/svn/R-devel/src/main/paste.c:174) ==2490768== by 0x4D92DD: bcEval_loop (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:8150) ==2490768== by 0x4E4461: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7533) ==2490768== by 0x4E4461: bcEval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:7518) ==2490768== by 0x4E482A: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1167) ==2490768== by 0x4E66C6: R_execClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2398) ==2490768== by 0x4E746F: applyClosure_core (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2314) ==2490768== by 0x4E4A38: Rf_applyClosure (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:2333) ==2490768== by 0x4E4A38: Rf_eval (/data/localhost/ripley/R/svn/R-devel/src/main/eval.c:1278) ==2490768== by 0x47EAE0: R_UnwindProtect (/data/localhost/ripley/R/svn/R-devel/src/main/context.c:984) ==2490768== by 0x1C18FA04: Rcpp::unwindProtect(SEXPREC* (*)(void*), void*) (/data/localhost/ripley/R/test-dev/Rcpp/include/Rcpp/unwindProtect.h:68) ==2490768== > ## view the output > Res Stratified Permuted Block Randomization Data: Real group = A B block = 4 Sample size = 100 cov_num = 3 considered covariates: gender age jobs level_num = 2 3 3 the first three patients' covariate-profiles and assignments: covariate1 covariate2 covariate3 assignment pat1 1 1 1 B pat2 1 1 1 A pat3 1 1 2 B Mean absolute imbalances at overall, within-strt., and within-cov.-margin levels: overall within-cov.-margin pnum = 1 pnum = 2 2.000 1.500 0.250 1.167 pnum = 3 pnum = 4 0.250 0.250 Remark-Index: 1 -- gender 1 <--> male; 2 <--> female 2 -- age 1 <--> 0-30; 2 <--> >50; 3 <--> 30-50 3 -- jobs 1 <--> others; 2 <--> stu.; 3 <--> teac. > > ## Simulated data > cov_num <- 3 > level_num <- c(2, 3, 3) > pr <- c(0.4, 0.6, 0.3, 0.4, 0.3, 0.4, 0.3, 0.3) > Res.sim <- StrPBR.sim(n = 100, cov_num, level_num, pr) > ## view the output > Res.sim Stratified Permuted Block Randomization Data: Simulated group = A B block = 4 Sample size = 100 cov_num = 3 level_num = 2 3 3 the first three patients' covariate-profiles and assignments: covariate1 covariate2 covariate3 assignment pat1 2 2 3 B pat2 1 2 2 A pat3 2 3 3 A Mean absolute imbalances at overall, within-strt., and within-cov.-margin levels: overall within-cov.-margin pnum = 1 pnum = 2 0.00 1.00 0.60 0.75 pnum = 3 pnum = 4 0.20 0.75 > > > > > cleanEx() > nameEx("boot.test") > ### * boot.test > > flush(stderr()); flush(stdout()) > > ### Name: boot.test > ### Title: Bootstrap t-test > ### Aliases: boot.test > > ### ** Examples > > #Suppose the data used is patients' profile from real world, > # while it is generated here. Data needs to be preprocessed > # and then get assignments following certain randomization. > set.seed(100) > df<- data.frame("gender" = sample(c("female", "male"), 100, TRUE, c(1 / 3, 2 / 3)), + "age" = sample(c("0-30", "30-50", ">50"), 100, TRUE), + "jobs" = sample(c("stu.", "teac.", "other"), 100, TRUE, c(0.4, 0.2, 0.4)), + stringsAsFactors = TRUE) > ##data preprocessing > data.pd <- StrPBR(data = df, bsize = 4)$Cov_Assig > > #Then we need to combine patients' profiles and outcomes after randomization and treatments. > outcome = runif(100) > data.combined = data.frame(rbind(data.pd,outcome), stringsAsFactors = TRUE) > > #run the bootstrap t-test > B = 200 > Strbt = boot.test(data.combined, B, "StrPBR", bsize = 4) > Strbt Bootstrap t-test data: data.combined t = 0.50134, p-value = 0.6161 95 percent confidence interval: -0.0806597 0.1361060 sample estimates: difference for treatment effect 0.02772313 > > > > cleanEx() > nameEx("compRand") > ### * compRand > > flush(stderr()); flush(stdout()) > > ### Name: compRand > ### Title: Compare Different Randomization Procedures via Tables and Plots > ### Aliases: compRand > > ### ** Examples > > ## Compare stratified permuted block randomization and Hu and Hu's general CAR > cov_num <- 2 > level_num <- c(2, 2) > pr <- rep(0.5, 4) > n <- 500 > N <- 20 # < bsize <- 4 > # set weight for Hu and Hu's method, it satisfies > # (1)Length should equal to cov_num > omega <- c(1, 2, 1, 1) > # Assess Hu and Hu's general CAR > Obj1 <- evalRand.sim(n = n, N = N, Replace = FALSE, cov_num = cov_num, + level_num = level_num, pr = pr, method = "HuHuCAR", + omega, p = 0.85) > # Assess stratified permuted block randomization > Obj2 <- evalRand.sim(n = n, N = N, Replace = FALSE, cov_num = cov_num, + level_num = level_num, pr = pr, method = "StrPBR", + bsize) > > RES <- compRand(Obj1, Obj2) > > > > > cleanEx() > nameEx("corr.test") > ### * corr.test > > flush(stderr()); flush(stdout()) > > ### Name: corr.test > ### Title: Corrected t-test > ### Aliases: corr.test > > ### ** Examples > > ##generate data > set.seed(100) > n = 1000 > cov_num = 5 > level_num = c(2,2,2,2,2) > pr = rep(0.5,10) > beta = c(0.1,0.4,0.3,0.2,0.5,0.5,0.4,0.3,0.2,0.1) > omega = c(0.1, 0.1, rep(0.8 / 5, times = 5)) > mu1 = 0 > mu2 = 0.7 > sigma = 1 > type = "linear" > p = 0.85 > > dataH = getData(n,cov_num,level_num,pr,type,beta, + mu1,mu2,sigma,"HuHuCAR",omega,p) > > #run the corrected t-test > HHct=corr.test(dataH) > HHct Corrected t-test data: dataH t = -11.107, p-value < 2.2e-16 95 percent confidence interval: -0.8260204 -0.5782327 sample estimates: difference for treatment effect -0.7021266 > > > > cleanEx() > nameEx("evalPower") > ### * evalPower > > flush(stderr()); flush(stdout()) > > ### Name: evalPower > ### Title: Evaluation of Tests and Randomization Procedures through Power > ### Aliases: evalPower > > ### ** Examples > > ##settings > set.seed(2019) > n = 100#< cov_num = 5 > level_num = c(2,2,2,2,2) > pr = rep(0.5,10) > beta = c(0.1,0.4,0.3,0.2,0.5,0.5,0.4,0.3,0.2,0.1) > omega = c(0.1, 0.1, rep(0.8 / 5, times = 5)) > di = seq(0,0.5,0.1) > sigma = 1 > type = "linear" > p = 0.85 > Iternum = 10#< sl = 0.05 > Reps = 10#< > #Evaluation of Power > library("ggplot2") > Strtp=evalPower(n,cov_num,level_num,pr,type,beta,di,sigma, + Iternum,sl,"HuHuCAR","rand.test",TRUE,omega,p,Reps, nthreads = 1) > Strtp $Powers diff value se 1 0.0 0.2 0.126 2 0.1 0.0 0.000 3 0.2 0.6 0.155 4 0.3 0.6 0.155 5 0.4 1.0 0.000 6 0.5 0.9 0.095 $Plot $Time [1] "Execute time: 8.69 secs" > > > > cleanEx() detaching ‘package:ggplot2’ > nameEx("evalRand") > ### * evalRand > > flush(stderr()); flush(stdout()) > > ### Name: evalRand > ### Title: Evaluation of Randomization Procedures > ### Aliases: evalRand > > ### ** Examples > > # a simple use > ## Access by real data > ## create a dataframe > df <- data.frame("gender" = sample(c("female", "male"), 1000, TRUE, c(1 / 3, 2 / 3)), + "age" = sample(c("0-30", "30-50", ">50"), 1000, TRUE), + "jobs" = sample(c("stu.", "teac.", "others"), 1000, TRUE), + stringsAsFactors = TRUE) > Res <- evalRand(data = df, method = "HuHuCAR", N = 500, + omega = c(1, 2, rep(1, ncol(df))), p = 0.85) > ## view the output > Res Hu and Hu's General CAR call: evalRand(method = HuHuCAR) group = A B Sample size = 1000 iteration = 500 cov_num = 3 level_num = 2 3 3 Data type: Real assignments of the first 3 iterations for the first 7 patients : pat1 pat2 pat3 pat4 pat5 pat6 pat7 iter1 B A B A B A B iter2 B A B A A B B iter3 B A B A A B A Evaluation by imbalances: absolute overall imbalances: max 95% quan median mean 6.000 2.000 0.000 0.812 absolute within-strt. imbalances for the first 3 strata: max 95% quan median mean stratum1(1,1,1) 5 3 1 1.23 stratum2(1,1,2) 5 3 1 1.22 stratum3(1,1,3) 5 3 1 1.22 absolute within-cov.-margin imbalances for 3 margins: max 95% quan median mean margin(1;1) 6 4 0 1.08 margin(2;1) 7 3 1 1.38 margin(3;1) 7 3 1 1.46 Remark-Index: 1 -- gender 1 <--> male 2 <--> female 2 -- age 1 <--> >50 2 <--> 0-30 3 <--> 30-50 3 -- jobs 1 <--> teac. 2 <--> others 3 <--> stu. > > ## Assess by simulated data > cov_num <- 3 > level_num <- c(2, 3, 5) > pr <- c(0.35, 0.65, 0.25, 0.35, 0.4, 0.25, 0.15, 0.2, 0.15, 0.25) > n <- 1000 > N <- 50 > omega = c(1, 2, 1, 1, 2) > # assess Hu and Hu's procedure with the same group of patients > Res.sim <- evalRand.sim(n = n, N = N, Replace = FALSE, cov_num = cov_num, + level_num = level_num, pr = pr, method = "HuHuCAR", + omega, p = 0.85) > > > > cleanEx() > nameEx("getData") > ### * getData > > flush(stderr()); flush(stdout()) > > ### Name: getData > ### Title: Data Generation > ### Aliases: getData > > ### ** Examples > > #Parameters' Setting > set.seed(100) > n = 1000 > cov_num = 5 > level_num = c(2,2,2,2,2) > beta = c(1,4,3,2,5,5,4,3,2,1) > mu1 = 0 > mu2 = 0 > sigma = 1 > type = "linear" > p = 0.85 > omega = c(0.1, 0.1, rep(0.8 / 5, times = 5)) > pr = rep(0.5,10) > > #Data Generation > dataH = getData(n, cov_num,level_num, pr, type, beta, + mu1, mu2, sigma, "HuHuCAR", omega, p) > dataH[1:(cov_num+2),1:5] X1 X2 X3 X4 X5 covariate1 1.0000 1.00000 2.00000 1.00000 1.00000 covariate2 1.0000 1.00000 2.00000 2.00000 1.00000 covariate3 2.0000 2.00000 2.00000 1.00000 2.00000 covariate4 1.0000 1.00000 2.00000 1.00000 2.00000 covariate5 2.0000 1.00000 1.00000 2.00000 1.00000 assignment 2.0000 1.00000 1.00000 2.00000 2.00000 outcome 13.9634 14.43592 16.00091 14.59801 13.28392 > > > > cleanEx() > nameEx("rand.test") > ### * rand.test > > flush(stderr()); flush(stdout()) > > ### Name: rand.test > ### Title: Randomization Test > ### Aliases: rand.test > > ### ** Examples > > ##generate data > set.seed(100) > n = 1000 > cov_num = 5 > level_num = c(2,2,2,2,2) > pr = rep(0.5,10) > beta = c(0.1,0.4,0.3,0.2,0.5,0.5,0.4,0.3,0.2,0.1) > mu1 = 0 > mu2 = 0.01 > sigma = 1 > type = "linear" > p = 0.85 > > dataS = getData(n, cov_num, level_num, pr, type, + beta, mu1, mu2, sigma, "StrBCD", p) > > #run the randomization test > library("ggplot2") > Strt = rand.test(data = dataS, Reps = 200,method = "StrBCD", + conf = 0.95, binwidth = 30, + p = 0.85) > Strt Randomization test data: dataS p-value = 0.005 95 percent confidence interval: -2.390275e-01 -4.226958e+54 sample estimates: difference for treatment effect -0.1913866 > > > > ### *