Closed FehrAaron closed 1 year ago
Ok, I guess I found the solution, by just adding the data to emmeans it works. But I have no idea why it is required only for the gls model and only when running in parallel. The change in the code above would be:
est_marginal_means = emmeans(model, specs = ~ time*factor)
Hmmm. I'm glad you found a workaround. The basic issue is that emmeans()
(actually ref_grid()
) requires two steps -- one to reconstruct the dataset, and the other to put together the reference grid. The data-recovery step is defined by a recover_data()
method which is different for each model class. That method for gls
is a bit dicey because of complications with weight functions and such (see the code for emmeans:::recover_data.gls
.) I think that is why it hits a snag.
Thanks, I will have a look!
Describe the bug
Parallelization of the emmeans function is not possible, if the input model is a gls model made with the nmle package. The code below works when run not in parallel (%do% instead of %dopar%) and can be parallelized if a normal linear model (lm(value ~ timepoint * factor, data = lm_in)) is used instead.
To reproduce
Expected behavior
The result dataframe should be formed containting the estimated marginal means for all samples.
Instead, an error occurs:
Error in { : task 1 failed - "Perhaps a 'data' or 'params' argument is needed"
Additional context
Vectorization of the code using lapply also did not work and lead to the same error.