Reputation: 19
When I run lmer with fixed and random effects, I get the following error:
Error in qr.default(X, tol = tol, LAPACK = FALSE) : NA/NaN/Inf in foreign function call (arg 1)
However I have already tested every column in my dataframe to make sure there aren't NAs before analysis. I have also added in na.action = na.omit
just in case with no success.
I'm not proficient at R to the point where I feel comfortable using the debug()
function, but I've seen some people suggest that in other posts. I did traceback()
but honestly not sure what I'm looking for there, I'll provide the output below though in case that is helpful.
I have one response variable, two fixed effects, and one random effect.
> head(df)
# A tibble: 6 x 8
seal_ID diveNum D_phase datetime Depth MSA rate_s HR
<chr> <dbl> <chr> <dttm> <dbl> <dbl> <dbl> <dbl>
1 Congaree 1 D 2018-04-06 14:47:40 4.76 0.246 0 117.
2 Congaree 1 D 2018-04-06 14:48:00 5.06 0.232 0.865 100.
3 Congaree 1 D 2018-04-06 14:48:20 5.78 0.227 0 49.7
4 Congaree 1 B 2018-04-06 14:48:40 8.5 0.0629 0 40.3
5 Congaree 1 D 2018-04-06 14:48:40 7.29 0.159 0 39.9
6 Congaree 1 DB 2018-04-06 14:48:40 7.5 0.538 0 42.0
#In my model I want to know how rate_s and Depth affect HR with seal_ID as random effect
> model<-lmer(HR ~ rate_s*Depth +(1|seal_ID), data = df, na.action = na.omit)
Error in qr.default(X, tol = tol, LAPACK = FALSE) : NA/NaN/Inf in foreign function call (arg 1)
#The results of my traceback()
> traceback()
11: qr.default(X, tol = tol, LAPACK = FALSE)
10: qr(X, tol = tol, LAPACK = FALSE)
9: chkRank.drop.cols(X, kind = rankX.chk, tol = 1e-07)
8: lme4::lFormula(formula = HR ~ rate_s * Depth +
(1 | seal_ID), data = df, control = structure(list(
optimizer = "nloptwrap", restart_edge = TRUE, boundary.tol = 1e-05,
calc.derivs = TRUE, use.last.params = FALSE, checkControl = list(
check.nobs.vs.rankZ = "ignore", check.nobs.vs.nlev = "stop",
check.nlev.gtreq.5 = "ignore", check.nlev.gtr.1 = "stop",
check.nobs.vs.nRE = "stop", check.rankX = "message+drop.cols",
check.scaleX = "warning", check.formula.LHS = "stop"),
checkConv = list(check.conv.grad = list(action = "warning",
tol = 0.002, relTol = NULL), check.conv.singular = list(
action = "message", tol = 1e-04), check.conv.hess = list(
action = "warning", tol = 1e-06)), optCtrl = list()), class = c("lmerControl",
"merControl")))
7: eval(mc, parent.frame(1L))
6: eval(mc, parent.frame(1L))
5: lme4::lmer(formula = HR ~ rate_s * Depth +
(1 | seal_ID), data = df)
4: eval(expr, p)
3: eval(expr, p)
2: eval.parent(mc)
1: lmer(HR ~ rate_s * Depth + (1 | seal_ID),
data = df)
Upvotes: 0
Views: 200
Reputation: 226162
This is quite surprising. You can avoid the particular step that's failing by using control = lmerControl(check.rankX = "ignore"))
in your lmer()
call, but I suspect you will run into trouble farther along the line.
The failure is occurring at the step where lmer
tries to check to see whether any sets of columns are multicollinear. The part that's failing can recapitulated more simply as:
X <- model.matrix( ~ rate_s * Depth, data = df)
qr1 <- qr(X, tol = 1e-7, LAPACK = FALSE)
Does this fail in the same way? What is summary(X)
? nrow(X)
?
Upvotes: 1