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

mincLmer will converge when specifying summary_type = "fixef", yet will not when summary_type = "ranef" or "both" #298

Open
Jeanne-Mance opened this issue Dec 6, 2021 · 4 comments

Comments

@Jeanne-Mance
Copy link

Hello,

I'm trying to use the random slopes of a mixed-effects model as an input for another statistical test, however I'm having issues with getting the mincLmer to run when specifying the summary_type to be "ranef". The models will converge, with a few non-converging voxels, and give outputs when the the summary_type is set to "fixef" (i.e., model1), however, the model will not run and will be sent into a fail state when the summary_type is set to "ranef" (i.e., model2). Photos of failure and from logs are below.

In trying to work through the issue with @gdevenyi, we've checked the mask, we've checked for any low level background in the average and they are both fine. We then used mincWriteVolume to save the "converged" column from model1. The model ran with few non-converging voxels, so we then reran model 1 with an optimizer "Nelder_Mead". We then had fewer points of convergence failure. We tried to apply this method to the "ranef" model (model2), including the safely = True, however the model still will still not run.

Would anyone have any insights into possible solutions to get a model with summary_type = "ranef" to run?

Please let me know if more information is needed.

Tristin

model1 <- 
  mincLmer(jacobians ~ time_month + (time_month||Id)
           , data = data 
           , mask = mask
           , parallel = c("sge", 200)
           , summary_type = "fixef", REML = T, lmerControl(optimizer = "Nelder_Mead"))

model2 <- 
  mincLmer(jacobians ~ time_month + (time_month||Id)
           , data = data 
           , mask = mask
           , parallel = c("sge", 200)
           , summary_type = "ranef", REML = T, lmerControl(optimizer = "Nelder_Mead"), safely =T)

Screen Shot 2021-12-01 at 9 08 48 AM
Screen Shot 2021-12-06 at 1 51 55 PM

@gdevenyi
Copy link
Contributor

gdevenyi commented Dec 6, 2021

Based on testing, the fact that this is failing even with safely=T and my looking at the code, I think the tryCatch bits don't apply to the summary function, and so non-converged voxels are breaking it.

@jasonlerch
Copy link
Contributor

With Chris no longer actively working on this code I can't promise a quick fix. I'll look into it when I have a bit of time (unless there's a patch coming from you guys).

Quick workaround is to use mincApply with your own wrapped lmer function. Will be slower than mincLmer, but should otherwise give the same answer.

@gdevenyi
Copy link
Contributor

gdevenyi commented Dec 7, 2021

Looking again at the code, the summary function does appear to be wrapped:
https:/Mouse-Imaging-Centre/RMINC/blob/master/R/minc_lmer.R#L151-L155

With Chris no longer actively working on this code I can't promise a quick fix.

:(

Quick workaround is to use mincApply with your own wrapped lmer function.

That makes certain assumptions about R ability. Will investigate.

@gdevenyi
Copy link
Contributor

gdevenyi commented Jan 17, 2022

A fortuitous discovery by another student doing the same thing. Her code runs with "|" as the ranef slope (correlated slopes) and fails with the same error as the initial report if run with "||" (uncorrelated slopes).

Update: It works with the original dataset with "|"!

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

3 participants