Closed parkyoobin closed 3 years ago
Thank you for bringing that to my attention, and digging through the code to find the issue. I know someone else ran into this issue, too. I'll see if there's a way of standardizing figuring out the clustering variable. If not, then the options I see immediately are (1) have the user input what their clustering variable is, (2) specifying in the documentation that the clustering variable needs to come at the end of the model specification (and perhaps outputting a specific error if that's not the case). Can you think of other solution options?
Can’t really think of anything else. Both sound like great solutions to me! Thanks again for the package!
On Oct 21, 2020, at 1:27 PM, Mairead notifications@github.com wrote:
Thank you for bringing that to my attention, and digging through the code to find the issue. I know someone else ran into this issue, too. I'll see if there's a way of standardizing figuring out the clustering variable. If not, then the options I see immediately are (1) have the user input what their clustering variable is, (2) specifying in the documentation that the clustering variable needs to come at the end of the model specification (and perhaps outputting a specific error if that's not the case). Can you think of other solution options?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
I followed the above, and moved my clustervariable to the end of my model, but am still seeing the error. Any helpful thoughts?
Error in if (variance_tracker == 0) { : missing value where TRUE/FALSE needed
model3 <- lme (CBCL~ Childage + GESTAGE + ga.mri2 + Hipp + m.ea.stotal.sb.18 + m.ea.stotal.sb.18:ResidHippV02all, data = data1_18mtrim, method = "ML", na.action = "na.omit", random = ~ Childage | ID, control = lmeControl(msMaxIter = 200))
@miamclean90 Do you know if any of your groups are only 1 row long, i.e. for some ID number there is only one participant? That's another circumstance that causes that variance_tracker == 0 error, which I have fixed but haven't pushed that update to CRAN yet.
For posterity I'll note that the cluster variable only has to be at the end of the equation when using lme4
. For nlme
, the random effects can be anywhere in the equation.
@mkshaw deleting groups of ID that are only 1 row long solved the problem. Thank you! I await the update to CRAN.
Noted in documentation, in 2bb041a8fcfea37576620f3d3d1492031d2818f6.
Thanks for the great package!
I had an error with my syntax that looks something like
model1<- lmer(satisfaction ~ (1|coupleid)+grat_c, data)**
and it seems to be because formula(model) doesn't order the variables the way you mentioned in the source code;
(b) group dataset by clustering variable temp_data_grouped <- temp_data %>% dplyr::group_by_at(formula_length) #group by the clustering variable, which is the last variable in the df (by virtue of how formula(model) works, where it pulls out the formula, and the last variable is on the other side of the |, i.e., the clustering variable)
in the earlier steps when I run formula(model1) and do the following, the cluster variable isn't the last variable in the all_vars list.
all_vars <- all.vars(formula(model)) formula_length <- length(all_vars) # this returns the number of elements in the all_vars list cluster_variable <- all_vars[formula_length] # pull cluster, we'll need it later
So my model runs fine if I change my syntax to
model1<- lmer(satisfaction ~ grat_c + (1|coupleid), data)
i.e., having the cluster variable at the end
but otherwise, it doesn't work the way it should because the cluster variable is not correctly identified.
Just thought it might be worth nothing it!