Error handling in MethodEvaluation package

Hi everyone,

while I was trying to run the sample code for the MethodEvaluation package using the data from my institution, I ran into some errors.

I found out that when running the packageOhdsiBenchmarkResults() function, insufficient error handling leads to the function not running at all.

calibrateLeaveOneOut <- function(leaveOutUnit) {
        subsetMinusOne <- filterSubset[filterSubset$leaveOutUnit != 
          leaveOutUnit, ]
        one <- subset[subset$leaveOutUnit == leaveOutUnit, 
          ]
        model <- EmpiricalCalibration::fitSystematicErrorModel(logRr = subsetMinusOne$logRr, 
          seLogRr = subsetMinusOne$seLogRr, trueLogRr = log(subsetMinusOne$targetEffectSize), 
          estimateCovarianceMatrix = FALSE)
        caliCi <- EmpiricalCalibration::calibrateConfidenceInterval(logRr = one$logRr, 
          seLogRr = one$seLogRr, model = model)
        null <- EmpiricalCalibration::fitNull(logRr = subsetMinusOne$logRr[subsetMinusOne$targetEffectSize == 
          1], seLogRr = subsetMinusOne$seLogRr[subsetMinusOne$targetEffectSize == 
          1])
        caliP <- EmpiricalCalibration::calibrateP(null = null, 
          logRr = one$logRr, seLogRr = one$seLogRr)
        one$calLogRr <- caliCi$logRr
        one$calSeLogRr <- caliCi$seLogRr
        one$calCi95Lb <- exp(caliCi$logLb95Rr)
        one$calCi95Ub <- exp(caliCi$logUb95Rr)
        one$calP <- caliP
        return(one)
      }
      subset <- lapply(unique(subset$leaveOutUnit), calibrateLeaveOneOut)
      subset <- do.call("rbind", subset)

This is the specific lines where I traced the error back to.

In my case, unique(subset%leaveOutUnit) had only one element, leading to logical operation errors in the EmpiricalCalibration::fitSystematicErrorModel function due to subsetMinusOne being empty:
Error in if (sd < 0) { : missing value where TRUE/FALSE needed

I am not completely confident about how this case should be handled, what this part intended to do. Can anybody help me?

Thank you in advance.

Answered in the issue tracker: Error handling for subsetMinusOne and one · Issue #8 · OHDSI/MethodEvaluation · GitHub

In the future, please don’t post the same issue in two locations

1 Like