Expected behavior
I expected that calls to PBmodcomp() would translate without error to pb_modcomp() with the third and later arguments moved into control = list()
Actual behavior
pb_modcomp() errors if n_sim is not specified
library(pbkrtest)
#> Loading required package: lme4
#> Loading required package: Matrix
set.seed(8712)
sug <- lmer(sugpct ~ block + sow + harvest + ( 1 | block:harvest ),data = beets, REML = FALSE)
sug_no.harv <- update(sug, .~. - harvest)
sug.pb.h <- PBmodcomp(sug, sug_no.harv, cl = 2)
# No `cl` specified
sug.pb.h.underscore <- pb_modcomp(sug, sug_no.harv)
#> Error in lme4::.simulateFun(object = sm, nsim = nsim, seed = seed): (nsim <- as.integer(nsim[1])) > 0 is not TRUE
sug.pb.h.underscore <- pb_modcomp(sug, sug_no.harv, control = list(nsim = 1000))
# `cl` specified
sug.pb.h.underscore <- pb_modcomp(sug, sug_no.harv, control = list(cl = 2))
#> Warning in mclapply(1:cl, function(i) {: all scheduled cores encountered errors
#> in user code
sug.pb.h.underscore <- pb_modcomp(sug, sug_no.harv, control = list(cl = 2, nsim = 1000))
Created on 2025-07-23 with reprex v2.1.1
Proposed solution
I think a simple nsim <- if (is.null(control$nsim)) 1000 else control$nsim in pb_modcomp() would solve this
Session info
sessionInfo()
#> R version 4.5.0 (2025-04-11)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.2 LTS
#>
#> Matrix products: default
#> BLAS: /opt/R/openval/rc_20250900/4.5.0/lib/R/lib/libRblas.so
#> LAPACK: /opt/R/openval/rc_20250900/4.5.0/lib/R/lib/libRlapack.so; LAPACK version 3.12.1
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
#> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
#> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#>
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> loaded via a namespace (and not attached):
#> [1] digest_0.6.37 fastmap_1.2.0 xfun_0.52 glue_1.8.0
#> [5] knitr_1.50 htmltools_0.5.8.1 rmarkdown_2.29 lifecycle_1.0.4
#> [9] cli_3.6.5 reprex_2.1.1 withr_3.0.2 compiler_4.5.0
#> [13] rstudioapi_0.17.1 tools_4.5.0 evaluate_1.0.3 yaml_2.3.10
#> [17] rlang_1.1.6 fs_1.6.6
Expected behavior
I expected that calls to
PBmodcomp()would translate without error topb_modcomp()with the third and later arguments moved intocontrol = list()Actual behavior
pb_modcomp()errors ifn_simis not specifiedCreated on 2025-07-23 with reprex v2.1.1
Proposed solution
I think a simple
nsim <- if (is.null(control$nsim)) 1000 else control$nsiminpb_modcomp()would solve thisSession info