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
0
0
Entering edit mode
16 months ago
Corey • 0

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 • 714 views
ADD COMMENT

Login before adding your answer.

Traffic: 2189 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6