Skip to content

Commit

Permalink
fix for small blocksizes
Browse files Browse the repository at this point in the history
  • Loading branch information
emitanaka committed Nov 25, 2023
1 parent 4e6b1b9 commit c3f9f6a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/permute.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ permute_parent_one_alg <- function(vid, udf, ntrts) {
# in this case subtract total trts
blocksizes_adj <- blocksizes
blocksizes_adj[blocksizes > ntrts] <- blocksizes_adj[blocksizes > ntrts] %% ntrts
nB <- length(blocksizes_adj)
nBlock <- sum(blocksizes_adj)
# ALgDesign doesn't like it when the number of units is about the same as the number
# of blocks
if(nBlock < (ntrts - 1 + nB)) {
return(sample(rep(sample(1:ntrts), length.out = nrow(udf))))
}
utils::capture.output({
# prevent "No improvement over initial random design" print out from AlgDesign
# where the design is balanced
Expand Down

0 comments on commit c3f9f6a

Please sign in to comment.