Closed jniedballa closed 2 years ago
Thanks! I thought I had fixed all the long formula issues, but clearly not. I re-used this code in unmarked and a few months ago I fixed it there to
char <- paste(formula, collapse=" ")
But never brought it back over to ubms. This seems to also work with your example, you see any other issues with this approach?
I guess it would be ok... but I also don't know enough about the inner workings of ubms to say with confidence. I'd be happy to try a development version of the package on my offending workflow and report back if you're uncertain.
Fixed in d9d619e.
In the process I discovered an issue when a formula specified random slopes for an R factor variable, which doesn't work properly. The workaround is to manually code them as indicator variables. I've added a better error message.
This is due to the way lme4 generates the random effects model matrix. I probably need to write my own code to handle this instead of using lme4.
Hi Ken, when using a very long model formula,
check_formula
throws this warning:It is because https://github.com/kenkellner/ubms/blob/36d9b88aa126ceb8fca1b236d57e99e199c8c629/R/submodel.R#L167 splits the formula and returns a vector of length > 1, of which only the first item is then checked for nested random effects.
deparse1()
instead ofdeparse()
would avoid that, but that's only for R4.0 and higher.char <- paste(deparse(formula_long, width.cutoff = 500L))
seems to work though.
Altenratively, if char is a vector of length > 1 (this might print unwanted output):
Here's a reproducible example:
Note: I didn't check how a long formula would affect get_reTrms a few lines below