This is a test version of Biostars. For the public version, visit https://www.biostars.org.
ciTools error with lme4 and add_ci: Error in quantile.default(newX[, i], ...) : missing values and NaN's not allowed if 'na.rm' is FALSE

I'm using lme4 (v.1.1-33) in R v.4.3.1 to create a generalized linear mixed model with a couple random effects and several fixed effects. I get no errors or warnings from this line.

fit<-glmer(formula= Response ~ (1|random1) + (1|random2) + fixed1*fixed2 + fixed3, family= Gamma(link="log"), data=df, na.action=na.omit, control = glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun=2e5)))

Model summary doesn't show anything unusual. Next, I try to add predicted values and confidence intervals to df using add_ci() (ciTools v.0.6.1).

df_wCI<-add_ci(df=df, fit=fit)

This returns the following error message:

Error in quantile.default(newX[, i], ...) : 
  missing values and NaN's not allowed if 'na.rm' is FALSE
In addition: Warning messages:
1: In predict.merMod(fit, newdata = ciTools_data$df_temp, re.form = NULL,  :
  unused arguments ignored
2: In lme4::bootMer(fit, my_pred, nsim = nSims, type = "parametric",  :
  some bootstrap runs failed (4/500)

I'm not concerned about the warning messages, but I'm failing to understand the error; there are no NAs in my raw data anywhere, and I threw na.omit in the model construction just in case. Where are these "missing values" being generated? For reference, I do not receive this error when changing the code to calculate prediction intervals via add_pi() instead, which executes quickly without a hitch. I don't have any trouble calculating coefficient CIs with confint() "Wald" or "boot" methods either. Any ideas what specifically could be going wrong with the add_ci() function?

Update: I discovered that this code occasionally works, if all bootstrap runs are successful. I might be able to help the chances by setting nSims lower than default (e.g., =100). When it works, Warning #2 doesn't appear and neither does the error message, and the function returns df_wCI with the additional columns.

glmms troubleshooting r citools lme4

0 answers

No answers yet.

Log in to answer this question.