Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling for subsetMinusOne and one #8

Open
MINGYUK opened this issue Jan 16, 2025 · 0 comments
Open

Error handling for subsetMinusOne and one #8

MINGYUK opened this issue Jan 16, 2025 · 0 comments

Comments

@MINGYUK
Copy link

MINGYUK commented Jan 16, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant