Error: missing value where TRUE/FALSE needed

Hi everyone

During run a special package, I encounter this error

Error in if (func.lambda(lower, X2, df, b = bb) * func.lambda(l.upper,  :
  missing value where TRUE/FALSE needed

main Code is

RMSEAfun <- function (X2, df, N, CI)
{
  bb <- (1 - CI)/2
  lower <- 0
  l.upper <- X2
  u.upper <- max(N, X2 * 5)
  if (func.lambda(lower, X2, df, b = bb) * func.lambda(l.upper,
                                                       X2, df, b = bb) > 0) {
    l.lambda <- 0
  }
  else {
    l.lambda <- uniroot(f = func.lambda, lower = lower, upper = l.upper,
                        X2 = X2, b = bb, df = df)$root
  }
  if (func.lambda(lower, X2, df, b = CI + bb) * func.lambda(u.upper,
                                                            X2, df, b = CI + bb) > 0) {
    u.lambda <- 0
  }
  else {
    u.lambda <- uniroot(f = func.lambda, lower = lower, upper = u.upper,
                        X2 = X2, b = CI + bb, df = df)$root
  }
  return(c(sqrt(l.lambda/(N * df)), sqrt(u.lambda/(N * df))))
}

How can i save my life?

It's impossible to answer without knowing func.lambda and all the arguments. You need to provide a reprex:

I use GDINA package and when I Run GDINA(data, q) i have no problem, but when I run modelfit function I encounter this problem. You can see my data in the below link

https://drive.google.com/file/d/1LHpOnCUyvSimdWtLvbUMrQPm1CgVjoir/view?usp=sharing

https://drive.google.com/file/d/1bm2ylPJOZzYuynHyGaOA-vGKNSFbg_3O/view?usp=sharing

This seems like a different question to the one above. To echo AlexisW, we don't have enough information to help you more than the info given in the error message.

The Gold-Standard method to present your problem problem in a way others can reproduce and start diagnosing it is with a reproducible example. I'd encourage mocking one up in a reply.

The error message missing value where TRUE/FALSE needed is telling you that a function is expecting a logical vector (ie one that have only TRUE or FALSE values), but the function was supplied with something else, I think an NA or NULL. Again, a reproducible example would be handy to diagnose the issue and as a starting point to start suggesting solutions.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.