drizopoulos / GLMMadaptive

GLMMs with adaptive Gaussian quadrature
https://drizopoulos.github.io/GLMMadaptive/
60 stars 14 forks source link

emmeans support doesn't return the link #45

Closed rvlenth closed 2 years ago

rvlenth commented 2 years ago

I received an issue related to this package -- https://github.com/rvlenth/emmeans/issues/378. It appears that your emmeans support methods work pretty well, but in a case where you have, say, a binomial family, the returned emmGrid object does not "know" that a logit link was used. This created some user confusion.

All that is needed is to find the link and include it in the list misc returned by emm_basis.MixMod(). Perhaps looking at the code for similar situations, e.g., emmeans:::emm_basis.lm (which also works for glm models) will be helpful.

drizopoulos commented 2 years ago

If understand correctly, what needs to be added is the line

misc = .std.link.labels(object$family, misc)

Could you perhaps confirm this?

rvlenth commented 2 years ago

It appears that misc does not yet exist so you need to initialize it; and you need to reference emmeans to find the function. So I think

misc <- emmeans::.std.link.labels(object$family, list())

may work, provided that object$family is constructed the same way is in glm.

You also need to ensure that this misc is included in what is returned.

rvlenth commented 2 years ago

PS - thought it doesn't have to be like glm. All you need is something from which you can extract $family and $link as strings. For example

> emmeans::.std.link.labels(list(family="binomial", link="logit"), list())
$tran
[1] "logit"

$inv.lbl
[1] "prob"
drizopoulos commented 2 years ago

OK, I have added it to the development version, and I will soon send it to CRAN.