Closed ProfessorPeregrine closed 2 weeks ago
The problem is not there; for one thing, data
is not NULL
; and you can check it:
> all.vars(eval(model$call[[2]]))
[1] "density" "percent" "cycle"
But there is a similar place -- https://github.com/rvlenth/emmeans/blob/48ab8009c1363c3fd22293b49f1841e61bb789ed/R/helpers.R#L419
... where an extra eval
is needed. With that change, which I will push up soon, it works correctly.
Thanks for reporting this.
Closing as I think this is resolved. BTW, the bug is actually in the Satterthwaite code, so if you had used mode = "asymp"
or mode = "appx-satt"
, you wouldn't see this bug.
When I create a new model (in this case a gls) I'd like to pass in a formula from a previous model (in this case lm). It seems like I could use formula(old_model) and if I do, the gls function works perfectly. But if I pass in that new gls model to emmeans() it fails with this error: Error in call$model[[2]] : object of type 'symbol' is not subsettable. On the other hand, if I create that new gls model by hand-typing the formula, that model works fine with emmeans().
Here is code to replicate the issue:
Expected behavior
emmeans() should take a valid model regardless of whether that model was created with a hand-typed or extracted formula.
Additional context
I posted this on StackOverflow:https://stackoverflow.com/questions/78664364/why-do-i-need-to-hardcode-the-formula-in-emmeans-instead-of-dynamically-extrac
The responder mentioned this code chunk for a clue on what might be happening: https://github.com/rvlenth/emmeans/blob/48ab8009c1363c3fd22293b49f1841e61bb789ed/R/helpers.R#L343-L348
Thank you very much for a great package! I have the workaround, but I hope this helps make the package better!