Skip to content

Commit

Permalink
fixed bug with bootstrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Gussenbauer - QM committed May 20, 2020
1 parent 9e71e86 commit 5ecb597
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions R/draw.bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ draw.bootstrap <- function(
# check single.PSUs
single.PSU <- single.PSU[1]
if (is.null(single.PSU) || !single.PSU %in% c("merge", "mean")) {
message("single.PSU was not set to either 'merge' or 'mean'!\n Bootstrap",
warning("single.PSU was not set to either 'merge' or 'mean'!\n Bootstrap",
" replicates for single PSUs cases will be missing!")
single.PSU <- FALSE
}
Expand Down Expand Up @@ -395,7 +395,7 @@ draw.bootstrap <- function(

# check for each stage that PSUs are not in mutiple strata
for(i in seq_along(strata)){
if(!strata[i]%in%c("1","I")){
if(!strata[i]%in%c("1","I") & !cluster[i]%in%c("1","I")){
countMultiple <- dt.eval("dat[,uniqueN(",strata[i],"),by=c(cluster[i],period)][V1>1]")
if(nrow(countMultiple)>0){
stop("Some sampling units in ",cluster[i]," occur in multiple strata of ",strata[i])
Expand Down
4 changes: 2 additions & 2 deletions R/rescaled.bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ rescaled.bootstrap <- function(

# check for each stage that PSUs are not in mutiple strata
for(i in seq_along(strata)){
if(!strata[i]%in%c("1","I")){
countMultiple <- dt.eval("dat[,uniqueN(",strata[i],"),by=c(cluster[i])][V1>1]")
if(!strata[i]%in%c("1","I") & !cluster[i]%in%c("1","I")){
countMultiple <- dt.eval("dat[,uniqueN(",strata[i],"),by=.(",cluster[i],")][V1>1]")
if(nrow(countMultiple)>0){
stop("Some sampling units in ",cluster[i]," occur in multiple strata of ",strata[i])
}
Expand Down

0 comments on commit 5ecb597

Please sign in to comment.