I was workinf on a dataset, trying re-perfomrming an already run statysical analysis and I met the following function:
binomial()$linkinv(fixef(m))
after running the following model
summary((m = glmer(var1 ~ str2 + (str2 | ID), single_data, family = binomial)))
My first question is what exactly does this functions is made for? Beacuse throgh other command lines the reciprocal code as well as a slightly modified code based always on it are also reported:
1) 1- binomial()$linkinv(fixef())
2) single_data$fit = binomial()$linkinv(model.matrix(m) %*% fixef(m)) #also the sense of the operator %*% is quite misterious too.
Thanks for your answers
I agree with most of @Oliver's answer. I will add a few comments (since I had an answer partly composed already).
I would be very wary of the script you are following: some parts look wrong (I could obviously be mistaken since these bits are taken completely out of context ...)
binomial()$linkinv
refers to the inverse link function for the model used. By default (which applies in this case since no optional link=
argument has been specified), this is the inverse-logit or logistic function A nearly equivalent function is available via plogis()
, but using $linkinv
could be better in some cases since it would generalize to binomial analyses done with other link functions [e.g. probit or cloglog].binomial()$linkinv(model.matrix(m) %*% fixef(m))
is indeed computing the predicted estimates on the link scale and converting them back to the data (= probability) scale. You can get the same results more reliably (handling missing values, etc.) by using predict(m, type = "response", re.form = ~0)
(this extends @Oliver's answer to a case that also applies the inverse-link function for you).binomial_pred_ci
is either, but I would suggest you look at predictInterval()
from the merTools
package ...PS these answers all have not much to do with runjags
, which uses an entirely different model structure. Presumably glmer
models are being fitted for comparison ...